Should put state in URL instead of useState (in React & Next.js)

Should put state in URL instead of useState (in React & Next.js). Users can share the url on chat and social media and refresh browser get the same UI

 Should put state in URL instead of useState (in React & Next.js)

Keeping this state in url has many benefits 👇
  • users can share the url on chat and social media and refresh browser get the same UI
  • users can bookmark the url and get the same UI
  • user can send the url to a new device and get the same UI
  • users can use the back/forward button to get the previous/next UI
  • users can open the url in a new tab / window and get the same UI
  • users can edit directly on url to get the UI they want
  • search engine optimization ranking — URLs with structured state data can improve search engine
  • users can save the url for themselves, e.g. in note taking app, to come back to same UI
  • later
  • can even stay a server component







Comment