Category: Next.js, React and TypeScript

Next.js parallel routes: After refresh the modal turns into 404

Read this guide in Polish

The navigation in the app opens modal, but a direct refresh of the current URL shows no matching of the parallel route. Parallel routes and intercepting routes may require default.tsx for slots that do not fit during full reload.

How to identify the source of the problem

Check the directory structure @slot, (.)segment and missing default.tsx files. Compare soft navigation with direct URL entry in the new window, especially for closed modals.

Compare the message from the console with the result of the production compilation and the condition after the page has been refreshed.

Repair steps

Add the provided default.tsx to parallel slots and provide a separate full page for direct navigation. Set the model closing semantics and browser history so Back does not lead to an empty view.

How to Test Solution

Soft navigation shows modal, and reload gives a working page or conscious fallback, instead of an accidental 404.

Security and restrictions

Do not treat the intercepted route as the only page available under a given URL.