OptionalParams in route not working

I'm not getting the expected result using optional params - routes -- users ---- [[id]].tsx ---- index.tsx -- [...404].tsx url: http://localhost:3000/users/1/2 [[id]].tsx
export default function UsersOptionalParams() {
return (
<div class="component">
<p class="file-name">routes/users/[[id]].jsx</p>
</div>
);
}
export default function UsersOptionalParams() {
return (
<div class="component">
<p class="file-name">routes/users/[[id]].jsx</p>
</div>
);
}
It is routing to [...404]
7 Replies
peerreynders
peerreynders7mo ago
It's working as expected: - /users/1 -> id = 1 - /users/1/2 -> page not found (there is no path to (/users/1)/2) Maybe you are looking for src/routes/users/[...id].tsx
peerreynders
peerreynders7mo ago
OK looks like I'm wrong.
peerreynders
peerreynders7mo ago
Compare with this
SolidStart Release Candidate Documentation
SolidStart Release Candidate Documentation
Early release documentation and resources for SolidStart Release Candidate
peerreynders
peerreynders7mo ago
I think optional simply means no need for index.tsx and [id].tsx; just use [[id]].tsx instead. To my knowledge /users/1/2 would require a catch-all route
Carl (klequis)
Carl (klequis)OP7mo ago
Logical. But in that case the doc seems to be wrong because in testing that it matches /users and /users/1 but not /users/1.2. I'll ask the cocs team.
Want results from more Discord servers?
Add your server