You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a side project of mine I am using Next.js - mostly for the built-in routing and SSG capabilities.
The app has only one dynamic route that is /pages/picture/[id].js and 20 pictures - a tiny JSON payload which I am reading from the FS at build time. To speed up navigation (next/prev via arrow keys) the page uses the array of metadata and a cursor which is kept in local state and used to select the next/prev image.
This works fine but when the user stops navigating I would eventually like to update the URL. I've tried to use next-router but it seems that when I push the new route "/picture/" + currentId the page is re-rendered which makes totally sense I guess.
Ideally I would like to avoid this and do a full page render only upon initial navigation. So I thought I can use the history API to push and handle popostate events but I was wondering if you'd suggest a different more Next.js-y approach.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For a side project of mine I am using Next.js - mostly for the built-in routing and SSG capabilities.
The app has only one dynamic route that is
/pages/picture/[id].js
and 20 pictures - a tiny JSON payload which I am reading from the FS at build time. To speed up navigation (next/prev via arrow keys) the page uses the array of metadata and a cursor which is kept in local state and used to select the next/prev image.This works fine but when the user stops navigating I would eventually like to update the URL. I've tried to use next-router but it seems that when I push the new route
"/picture/" + currentId
the page is re-rendered which makes totally sense I guess.Ideally I would like to avoid this and do a full page render only upon initial navigation. So I thought I can use the history API to push and handle
popostate
events but I was wondering if you'd suggest a different more Next.js-y approach.Thanks in advance for your help!
Beta Was this translation helpful? Give feedback.
All reactions