Closed gregfenton closed 5 months ago
Hey @gregfenton, I've been using config-based approach for defining private/protected routes for a while, it works well and it's compatible with other file-based routing systems (Next.js, etc.) — here's a reference to a previous issue https://github.com/oedotme/generouted/issues/111#issuecomment-1676025682
You can use the pathless groups/layouts as well on top of that for organization sake, the redirects
config would be the main place to handle the protection of routes and appropriate redirection, the structure would be something like that:
src
├── config
│ └── redirects.tsx
├── main.tsx
├── pages
│ ├── _app.tsx
│ ├── (dashboard)
│ │ └── profile.tsx
│ └── (public)
│ └── login.tsx
└── router.ts
Thanks for pointing that out, I'm now thinking to add a section to the docs to include some common use cases.
That's awesome, thanks! I suspect a clearer callout to this pattern would be very much appreciated by newcomers and to the curious 😁
How do protected routes work under generouted?
I would consider this to be a "convention", or at least have a special call out to this important use case. I was looking for info regarding "guard routes" or "protected routes" but it didn't jump out at me from the docs. I see there is a concept of pathless layouts but there is little detail as to their purpose (pathless?) or how the work.
[If there is a better place to ask questions, like a Discord server or something, I'd be happy to be redirected].