#default route

1 messages · Page 1 of 1 (latest)

near tendon
#

What is the best way to specify which child route should be loaded if the url only mentions the parent? I know there is the index.tsx file for this but it's more about redirecting to one of the child routes dynamically upon navigation to the parent url instead of having a default child route.

coral hornet
#

create an index file nested inside the parent route, export a loader and redirect the user to some other specific child route

// routes/parent/index.tsx
export async function loader() {
  return redirect("/parent/child")
}
near tendon
#

oooh I was almost there, was trying to use relative url though like redirect("./general")

coral hornet
#

sadly redirect doesn't support relatives URLs

#

this is an HTTP limit

#

redirects need the full URL or at least an absolute one for the current host

near tendon
#

ok I was confused with the "to" attribute on Links, got it.
OT: how do you put code snippets in a discord message? ^^'

coral hornet
#

using the ` character three times

#

after the third one you can include the language like ts

limber spindle
#

Does ‘Link’ support relative paths in Remix?

coral hornet
#

Yea

willow stratus
#

Can we use a react-router hook? useResolvedPath maybe?