Search code examples
reactjsreact-router-domaws-amplify

How to share a link to a React app route?


I'm using using react 17 and react-router-dom 6 within my client side app. I want my users to have the ability to share links between each other like this one https://example.com/id/8dcbe502-cc71-4199-8dfa-b84377d6b066. But when I'm trying to open the link, I get an error from my server. I guess that's because the react app has not been loaded at this time and the path does not exists physically on the server. The app is hosted with AWS amplify hosting.

When clicking on a link pointing to localhost with the react app running locally, everything works fine and the desired component gets rendered.

How to properly handle such case and share links to a react app route?


Solution

  • In the end, the simplest solution for me was to switch to a react framework which supports sharing links. I decided for next.js. Now its working.