Skip to content

Update Auth Kit from v1 to v2

What's changed

  • React Auth Kit v2 comes with the support of React Router v6.
  • React Auth Kit v2 stops using the PrivateRoute component.
  • React Auth Kit v2 introduces new component named RequireAuth.
  • RequireAuth will replace the use-cases of PrivateRoute. It also will make the process easier to manage.

Update to v2

Component structure in v1

RouteComponent
<BrowserRouter>
  <Switch>
    <Route path={'/'} component={Home} exact/>
    <Route path={'/login' } component={Login} exact/>
    <PrivateRoute path={'/secure'}
                  component={SecureComponent}
                  loginPath={'/login'} exact
    />
  </Switch>
</BrowserRouter>

Component structure in v2

RouteComponent
<BrowserRouter>
  <Routes>
    <Route path={'/'} element={<Home/>}/>
    <Route path={'/login' } element={<Login/>}/>
    <Route path={'/secure'} element={
        <RequireAuth loginPath={'/login'}>
          <SecureComponent/>
        </RequireAuth>
    }/>
  </Routes>
</BrowserRouter>

— 🔑 —

React Auth Kit is Apache 2.0 License code