Next.js · Middle · Question 64 of 75

How can a deeply nested server component read the [lang] segment of the root layout without prop drilling?

import { lang } from 'next/root-params'

const current = await lang()

Explanation

Root params are dynamic segments above the root layout. The getters work in server components but not in client components, Server Actions or Route Handlers.

Further reading

Problem with a question

Next.js · Middle · question 64

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz