How to get incoming request headers in Next js 14 App Directory
Answered
Nile Crocodile posted this in #help-forum
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
4 Replies
@Nile Crocodile 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?
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
Answer
Nile CrocodileOP
Awesome. Thanks. I have seen it's possible to use it in the layout too