Next.js · Junior · Question 43 of 75

How does template.tsx differ from layout.tsx?

Explanation

A template wraps pages like a layout but gets a unique key on each navigation: state resets and effects run again. This is useful, for example, for enter animations or logging page views. In most cases a layout is enough.

Further reading

Problem with a question

Next.js · Junior · question 43

Test yourself

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

Take this quiz