How to define multiple routes with same route file #5395
Unanswered
juniorforlife
asked this question in
Q&A
Replies: 1 comment 4 replies
-
You need to give each route a unique id... by default, Remix uses the file path without extension. routes: async (defineRoutes) => {
return defineRoutes((route) => {
route("/", "routes/__main.tsx", { id: 'routes/__main-index' }, () => {
route("/", "routes/__main/home.tsx", { id: 'routes/__main/home-index' });
});
route("/home", "routes/__main.tsx", () => {
route("/home", "routes/__main/home.tsx");
});
});
} |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have 4 pages:
home
,library
sharing the same layout which has a header & footerlogin
andsignup
no header & footerSo my folder structure is like this:
What I'm trying to do is to have both
/
and/home
end up in the same route filehome.tsx
.I tried adding this code in
remix.config.js
:It works for
/
but when I visit/home
it will throw 404 error.If I make it like this
then Remix throws error saying
Unable to define routes with duplicate route id: "routes/__main"
What should be the right way to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions