Skip to content
Discussion options

You must be logged in to vote

Ok, I found out a structure that works for me:

routes/
  __root.tsx
  _auth.tsx <-- here is the magic to redirect to `/` if already authenticated in `beforeLoad`
  _auth/
    login.lazy.tsx
    register.lazy.tsx
  _authenticated.tsx <-- here is the magic to redirect to `/login` if not authenticated in `beforeLoad`
  _authenticated
    dashboard.lazy.tsx
    route-a.lazy.tsx
    route-b.lazy.tsx

That way I can also define a Layout for each in either _auth.tsx or _authenticated.tsx with the component attribute in the route and render an <Outlet /> at the appropriate position.

Replies: 3 comments 3 replies

Comment options

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

Comment options

You must be logged in to vote
2 replies
@thejasonxie
Comment options

@thejasonxie
Comment options

Answer selected by wolflu05
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants