When a site has a dialog, it's often done purely in JS, with no "pages" (ie. routing) involved. However, sometimes you want your dialog to have it's own URL, so that if the user refreshes the page, they come back to the page with the dialog up.
In Next.js I've managed most of the above. I have a base page route, and then a second route which renders that page component, plus my dialog component. When I click the link it changes the URL, and then I see my dialog ... and if I refresh, I still see the page/dialog.
However, when I first click the link, it re-renders the page, losing other stateful changes. I thought that using the shallow prop on my link would prevent this, but it didn't (I guess because the dialog routes were different routes, and not just query parameters?). I also thought perhaps using as instead of href would work ... but it turns out href is required.
So, to summarize, is it possible in Next.js to create a link which:
- does change the URL (to an actual page, not just the query parameters)
- does render a new (dialog) component
- doesn't re-render the main page component
P.S. I'm porting a site from Gatsby, where this is possible, and while I could change my routes to use query parameters instead of real routes, that would effectively "delete" a bunch of pages on my site ... with SEO consequences :(