import SuperTokens, { SuperTokensWrapper } from "supertokens-auth-react"; import { getSuperTokensRoutesForReactRouterDom } from "supertokens-auth-react/ui"; import { SessionAuth } from "supertokens-auth-react/recipe/session"; import { BrowserRouter, Routes, Route, Link } from "react-router-dom"; import * as ReactRouter from "react-router-dom"; import Dashboard from "./Dashboard"; import { PreBuiltUIList, SuperTokensConfig, ComponentWrapper } from "./config"; import Home from "./Home"; // Initialize SuperTokens - ideally in the global scope SuperTokens.init(SuperTokensConfig); function App() { return (
} /> {/* This shows the login UI on "/auth" route */} {getSuperTokensRoutesForReactRouterDom( ReactRouter, PreBuiltUIList )} {/* This protects the "/dashboard" route so that it shows only if the user is logged in. Else it redirects the user to "/auth" */} } /> separator
); } export default App;