Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next.js - route based modal

When using Next.js, I want to show a modal based on a url, on top of another page.

If gallery.js is the page component, I want /gallery/image/1232132 to display a modal with an image, on top of the gallery page.

Is that possible?

like image 442
Nir Ben-Yair Avatar asked Dec 18 '22 22:12

Nir Ben-Yair


1 Answers

This question is a bit old, but since March 2020 there's a full example on the official Next.js repo (you should probably use this since it must be the "recommended way" by the maintainers):

https://github.com/vercel/next.js/tree/canary/examples/with-route-as-modal

Here's the original issue:

https://github.com/vercel/next.js/issues/8023

And the related PR:

https://github.com/vercel/next.js/pull/11473

like image 125
Anatole Lucet Avatar answered Jan 25 '23 13:01

Anatole Lucet