Layout Question
Answered
In&Out posted this in #help-forum
In&OutOP
If something like this is possible, why isn't it in docs?
"use server";
import styles from "../_components/Main.module.css";
import UpperNavbar from "../_components/UpperNavbar";
import Sidebar from "./_components/Sidebar";
async function DynamicRouteEditorLayout({
children,
params,
}: {
children: React.ReactNode;
params: Promise<{ custom_page: string }>;
}) {
const { custom_page } = await params;
return (
<div className={styles.Container}>
<UpperNavbar />
<div className={styles.ContentContainer}>
<Sidebar />
<div className={styles.Content}>{children}</div>
</div>
</div>
);
}
export default DynamicRouteEditorLayout;
Answered by Asian black bear
Params for layouts are in the docs: https://nextjs.org/docs/app/api-reference/file-conventions/layout#params-optional
Also, don't use
Also, don't use
'use server'
for layouts.5 Replies
In&OutOP
To get params from layout file
Asian black bear
Params for layouts are in the docs: https://nextjs.org/docs/app/api-reference/file-conventions/layout#params-optional
Also, don't use
Also, don't use
'use server'
for layouts.Answer
@In&Out why not?
Asian black bear
Because they aren't server actions.
@Asian black bear Because they aren't server actions.
In&OutOP
ah, okay, thanks