Next.js Discord

Discord Forum

Layout Question

Answered
In&Out posted this in #help-forum
Open in Discord
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 'use server' for layouts.
View full answer

5 Replies

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 '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.
ah, okay, thanks