Next.js · Senior · Question 31 of 75

How does unstable_rethrow help with error handling?

Explanation

Next.js uses exceptions for control flow: redirect, notFound, dynamic rendering signals. A broad try/catch swallows them and breaks behavior. unstable_rethrow(err) at the start of catch rethrows such errors and leaves you only the "real" ones.

Further reading

Problem with a question

Next.js · Senior · question 31

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