react-router-guard-ts is based on react 18, react-router 6 and Typescript JSX. It can realize the function of authentication, guard, lazy load, loading status and check of route by configuration.
First, you need to save
this file
to ./router/guard.tsx
import RouterGuard from './router/guard'
import {routes, onRouteBefore} from './router'
function App() {
return (
<RouterGuard
routers={routes}
onRouterBefore={onRouteBefore}
/>
)
}Routes
routes list config
Authentication
guard config
Auth check
guard config