Next.js Discord

Discord Forum

How to get incoming request headers in Next js 14 App Directory

Answered
Nile Crocodile posted this in #help-forum
Open in Discord
Nile CrocodileOP
Previously, in _app.tsx that was the entry point of our application, we could get the request headers as shown below; How do we do it in the Root Layout in app directory?
Answered by B33fb0n3
you can get the headers by accessing them via the headers function. You can read more about it here: https://nextjs.org/docs/app/api-reference/functions/headers#examples
View full answer

4 Replies

Answer
Nile CrocodileOP
Awesome. Thanks. I have seen it's possible to use it in the layout too