Nested layouts with dynamic route

I am using solid start with file based routing. I want to create routes with nested layout. I want to have routes /plans/[id] and /plans/[id]/select. Both of these routes should share same layout, how can I acheive it with dynamic paremeter?
4 Replies
Udit
Udit4d ago
I think start first by creating a folder called plan, then nest a folder named [id] and nest the file like select.jsx/tsx. In order to specify a layout create an index.jsx/tsx or (plan).jsx/tsx page in plan folder. In that file,return a default component which accepts children as props and render {props.children} in that component.
radek1313
radek1313OP4d ago
But I want only shared layout only for /plans/[id] and /plans/[id]/select . I already have plans folder. There I have index.tsx which is route for all plans. I have also [id].tsx route there which is for plan details. I want to add now route /plans/[id]/select which should have shared layout only with /plans/[id]. Sorry for confusion, should clarify it in the first message
Brendonovich
Brendonovich4d ago
plans/
[id].tsx // layout
[id]/
index.tsx // /plans/[id]
select.tsx // /plans/[id]/select
plans/
[id].tsx // layout
[id]/
index.tsx // /plans/[id]
select.tsx // /plans/[id]/select
that should do it
radek1313
radek1313OP4d ago
this works, but there is problem if I open /plans/[id] and /plans/[id]/select diirectly. If I go to this page with Link component it works fine
No description
Want results from more Discord servers?
Add your server