Next.js Discord

Discord Forum

Next.js App Router: async arrow vs. async function in nested layout?

Unanswered
Fred posted this in #help-forum
Open in Discord
I’m exporting an async arrow function as default. It seems to work in nested layouts, but I heard it’s not valid for app/layout.tsx. Is this safe for nested routes like /documentation/layout.tsx or should I use a default async function instead?

const DocumentationLayout = async ({
  children
}: {
  children: React.ReactNode
}) => {
  const pageMap = (await getPageMap()).filter(isMdxFile)

  return (
    <Layout pageMap={pageMap} feedback={{ content: null }} editLink={false}>
      {children}
    </Layout>
  )
}

export default DocumentationLayout

2 Replies