tatethurston / nextjs-routes

Type safe routing for Next.js
MIT License
580 stars 21 forks source link

feature: typed query params #205

Closed cleisonmp closed 1 month ago

cleisonmp commented 1 month ago

Would it be possible to add typed search params ex page, search, or other states we want to lift to the url?

Maybe even if it's just a generic to useRouter ex: useRouter<'/accounts',UrlStates>()

tatethurston commented 1 month ago

Hey @cleisonmp is this a duplicate of https://github.com/tatethurston/nextjs-routes/issues/39?

The issue with adding a second type argument like this is that it doesn't provide any type safety, it just hides the cast. This would be the same as doing:

const query = useRouter().query as UrlStates
cleisonmp commented 1 month ago

Hey @cleisonmp is this a duplicate of #39?

It's I missed that due to the title, sorry. That routers:{} solution you proposed would be awesome.