Skip to content

Multiple index routes #1073

Closed Answered by ryanflorence
sigginjals asked this question in Q&A
Dec 16, 2021 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Getting me defensive over here with "not very flexible", the router is incredibly flexible! It just doesn't deal with hostnames, only pathnames.

But you can change your UI based the host by sending the information down from your loader:

export function loader({ request }) {
  let url = new URL(request.url);
  return { hostname: url.hostname }
}

export default function Index() {
  let { hostname } = useLoaderData();
  return hostname === "cheese" ? <Cheese /> : <Beef />
}

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by machour
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@sigginjals
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants