Router API types #78435
ravinggenius
started this conversation in
Ideas
Router API types
#78435
Replies: 1 comment 2 replies
-
I guess there's less of an appetite for this than I thought. Would a merge request be welcome? I'm happy to do the work if there is interest. (I mean it's basically done already.) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
Background
I want to have accurate types for the "conventional files" used by the App Router. When creating a new page for instance, the editor doesn't know what type the page component props are. It types
params
asany
. Next does export some relevant types, such asMetadata
andNextRequest
. Recently I discovered thatParams
andSearchParams
are technically available, but only fromnext/dist/server/request/params
andnext/dist/server/request/search-params
respectively. These are accurate according to the description in the docs, but using them feels wrong.As a work-around I've been defining the types (as described by the docs) and maintaining them as part of my project. However when Next 15 was released, I had to update the types to account for the new async API.
Proposal
Below are the types I define for my project. It would be much more convenient to import them directly from Next, where they would be available for everyone. I'm happy to provide a patch if there is any interest for it.
next/app-router
might be good, but perhaps another source is preferred?(
Params
andSearchParams
should be properly exported too.)Beta Was this translation helpful? Give feedback.
All reactions