Next.js · Senior · Question 21 of 75

Why are Context providers in the App Router moved into a separate client component?

Explanation

createContext and providers are client features. You create providers.tsx with 'use client' and render it in the root layout around children. That way children stay server components. Providers are placed as deep as possible so more of the tree stays static.

Further reading

Problem with a question

Next.js · Senior · question 21

Test yourself

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

Take this quiz