-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #889 from supertokens/add-react-router-callout
Add info on a separate react-router use case
- Loading branch information
Showing
4 changed files
with
47 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
:::important | ||
If you are using `useRoutes`, `createBrowserRouter` or have routes defined in a different file, you need to adjust the code sample. | ||
Please see [this issue](https://github.com/supertokens/supertokens-auth-react/issues/581#issuecomment-1246998493) for further details. | ||
```tsx | ||
import React from 'react'; | ||
|
||
import { BrowserRouter, useRoutes } from "react-router-dom"; | ||
import SuperTokens, { SuperTokensWrapper } from "supertokens-auth-react"; | ||
import { getSuperTokensRoutesForReactRouterDom } from "supertokens-auth-react/ui"; | ||
import * as reactRouterDom from "react-router-dom"; | ||
|
||
function AppRoutes() { | ||
const authRoutes = getSuperTokensRoutesForReactRouterDom( | ||
reactRouterDOM, | ||
[/* Add your UI recipes here e.g. EmailPasswordPrebuiltUI, PasswordlessPrebuiltUI, ThirdPartyPrebuiltUI */] | ||
); | ||
|
||
const routes = useRoutes([ | ||
...authRoutes.map(route => route.props), | ||
// Include the rest of your app routes | ||
]); | ||
|
||
return routes; | ||
} | ||
|
||
function App() { | ||
return ( | ||
<SuperTokensWrapper> | ||
<BrowserRouter> | ||
<AppRoutes /> | ||
</BrowserRouter> | ||
</SuperTokensWrapper> | ||
); | ||
} | ||
``` | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters