Layouts
In RedwoodSDK, layouts are simply React components that provide consistent structure and styling around your page content. Unlike some frameworks that automatically apply layouts to multiple pages based on file location, RedwoodSDK layouts are explicitly imported and used in each component where needed.
-
Create a layouts directory to organize your layout components:
Directorysrc/
Directoryapp/
Directorylayouts/
- …
-
Create a basic layout component:
src/app/layouts/MainLayout.tsx export default function MainLayout({ children }:{children: React.ReactNode}) {return (<><Header /><main>{children}</main><Footer /></>);} -
Use the layout in your page components:
src/app/pages/HomePage.tsx import MainLayout from '../layouts/MainLayout'export default function HomePage() {return (<MainLayout><h1>Hello World</h1><p>This is the dream.</p></MainLayout>);}