-3

Blockquote

How do I route to the next page or another page using VITE?

Ijay
  • 15
  • 4

3 Answers3

0

I have the same problem, using vite, to redirect to another page we need to import the following lib:

import { navigate } from 'vite-plugin-ssr/client/router';

Don't need to create const variables, but have a caveat, this just work using Client Routing, on the other hand, you can use:

window.location.href = YOUR ROUTE

See the documentation for more information.

nima
  • 7,796
  • 12
  • 36
  • 53
0

In Vercel this can be done by adding a rewrite to config file in the root of the project called

vercel.json

https://vercel.com/docs/configuration Add rewrites for all routes to the file that point to '/' or '/index.html'

{
  "rewrites": [{ "source": "/(.*)", "destination": "/" }]
}

or

{
  "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}

Refence: Vite.js React Build Not Redirecting On Netlify And Vercel

Franco Petra
  • 688
  • 7
  • 18
-1

All your routing can be done via react-router-dom

Use Navigate, Redirect or useNavigate provided by react-router-dom

Please go through the docs and try to implement before asking

user18821127
  • 318
  • 1
  • 8