Remix-run/react: @2.9.2
Whenever a user visits my web page, such as "https://domainname.com"
, I would like it to automatically resolve to "https://domainname.com/shop/all"
I have a dynamic route under my app/routes folder: shop.$shopFilter
, and two links in my root.tsx JSX:
<ul>
<li>
<Link to={'/shop/all'}>shop all</Link>
</li>
<li>
<Link to={'/shop/clothes'}>shop clothes</Link>
</li>
</ul>
Is it possible to force the root route to resolve to the "/shop/all"
dynamic route, and thus execute the logic within that component as if the user clicked on my link to the "/shop/all"
route in remix-run?
The simplest way is to create an index route that redirects to the correct URL.
// routes/_.index.tsx
import { redirect } from '@remix-run/node'
export const loader = () => redirect('/shop/all')
As soon as the user visits https://domainname.com it will redirect to https://domainname.com/shop/all