Various issues with typed routes in v15.5.x #83182
Replies: 1 comment
-
Agree, I faced all issues that you described before What I found is that as soon as we have a dynamic route, it might not be as type-safe as you think. For instance, let’s say you have the following routes:
IMO, I don't think the current It would be great if NextJS can use this |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I've recently upgraded our website to v15.5.2 of next.js to take advantage of the new typed routes feature but i've hit a number of issues that have prevented us from enabling it. I know there are some limitations with the feature but I wanted to share to see if all the issues i'm experiencing are known limitations or maybe i'm just missing something
Additional information
The following issues can be observed from this code sandbox link: https://codesandbox.io/p/devbox/zyvxq4?embed=1&file=%2Fapp%2F%5Blocale%5D%2Fpage.tsx
Issues:
(It is normally valid to omit the locale prefix as it should use the default locale)
trailingSlash: true
(See "Problem 2" from the code sandbox link)href
for theLink
component (See "Problem 3" from the code sandbox link)One final issue can be observed from a different code sandbox link: https://codesandbox.io/p/devbox/next-js-typed-routes-issues-forked-6x3hgr?file=%2Fapp%2F%5Blocale%5D%2Fpage.tsx&workspaceId=ws_PxtS69w55nJsGarF8yBZoD
[...rest]
route to trigger thenotFound()
function (this is for handling any invalid paths to show a custom error message) we basically lose all type safety on our Links because the generated route types become too permissiveExample
https://codesandbox.io/p/devbox/zyvxq4?embed=1&file=%2Fapp%2F%5Blocale%5D%2Fpage.tsx
Beta Was this translation helpful? Give feedback.
All reactions