Use the src directory and follow the React Guidelines - Directory Structure.
Dynamically import layouts and render them in the App
component as this prevents the layout component to lose its state upon navigation.
Set the desired layout name and properties on object properties of the page component:
// pages/index.tsx
setLayout(HomePage, "SomeLayout", { props: { foo: 'bar' } })
You can then retrieve the layout component and properties in the App
component:
// pages/app.tsx
export default function App({ Component, pageProps }: AppProps) {
const [Layout, layoutProps] = usePageLayout(Component)
return (
<Layout {...layoutProps} >
<Component {...pageProps} />
</Layout>
)
}
Please read React Guidelines first.
TODO.
TODO.