Create a catchall dynamic route in remix

I’m using remix to serve my react application.
All my pages have dynamic slugs, therefore I need to find a way to resolve the following type of URL:

If I create an $index.jsx file in the routes folder it works in that all the dynamic URLs resolve to that file, BUT, I can’t seem to find a way to then read the slug in the compontent so that I serve the right data.

Many thanks to any responders.

>Solution :

You access the dynamic params via the params object passed to your loaders and actions.

// routes/$index.jsx

export async function loader({request, params, context}) {
  const slug = params.index // whatever $name is

Leave a Reply