@adan
To add a shared layout when using Next.js and Auth0, you can create a custom App component that wraps all your pages with the shared layout. Here is an example of how you can do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// components/Layout.js export default function Layout({ children }) { return ( <> <header> {/* Your header content here */} </header> <main>{children}</main> <footer> {/* Your footer content here */} </footer> </> ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// pages/_app.js import { Auth0Provider } from "@auth0/auth0-react"; import Layout from "../components/Layout"; function MyApp({ Component, pageProps }) { const domain = process.env.NEXT_PUBLIC_AUTH0_DOMAIN; const clientId = process.env.NEXT_PUBLIC_AUTH0_CLIENT_ID; return ( <Auth0Provider domain={domain} clientId={clientId} redirectUri={window.location.origin} > <Layout> <Component {...pageProps} /> </Layout> </Auth0Provider> ); } export default MyApp; |
That's it! You have now added a shared layout when using Next.js and Auth0.