aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/router.tsx
blob: 77158f4cc80601a42e15ff70c29eb478f8a6c34a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { createBrowserRouter, createHashRouter } from 'react-router'
import App from './App'
import { pageRoutes } from './route-config'

const isHashRouter = import.meta.env.VITE_ROUTER_MODE === 'hash'
const createRouter = isHashRouter ? createHashRouter : createBrowserRouter

export const router = createRouter([
  {
    path: '/',
    Component: App,
    children: pageRoutes,
  },
], {
  // The deployment base precedes the hash and must not be repeated inside it.
  basename: isHashRouter ? '/' : import.meta.env.BASE_URL,
})