tatethurston / nextjs-routes

Type safe routing for Next.js
MIT License
571 stars 23 forks source link

export to interface #38

Closed tatethurston closed 2 years ago

tatethurston commented 2 years ago

This so cool. I will use it, but can you export it to an interface too? Sometimes need use like this

const myText=`this is a link ${ROUTES.ITEM({itemId:"abcdefg"})} `

Originally posted by @IRediTOTO in https://github.com/vercel/next.js/discussions/28622#discussioncomment-3126130

tatethurston commented 2 years ago

@IRediTOTO Thanks for the kind words. Could you expand on what ROUTES.ITEMS. returns? Is it the pathname?

And do you want an interface to type the arguments to ROUTES.ITEMS or to have ROUTES.ITEMS generated as well?

IRediTOTO commented 2 years ago

Hi, I mean

const ROUTES={
ITEM:(itemId)=>{
return `/just-a-link/${itemId}`
}}

// same as
/just-a-link/[itemId]
tatethurston commented 2 years ago

I think there is some overlap here with #36. To date, this library only generated types and this would require generating a runtime.

I’ll think on this.

sachinraja commented 2 years ago

This API seems kind of similar to https://github.com/aspida/pathpida. I really like how nextjs-routes is just a drop-in solution right now (with no runtime impact!).

IRediTOTO commented 2 years ago

This API seems kind of similar to https://github.com/aspida/pathpida. I really like how nextjs-routes is just a drop-in solution right now (with no runtime impact!).

Look like this is what i am searching.

tatethurston commented 2 years ago

Yeah pathpida looks great if you want a runtime

tatethurston commented 2 years ago

If there is sufficient interest in a runtime I’ll look into it for nextjs-routes but pathpida seems to fill this need.

tatethurston commented 2 years ago

This has been implemented and released in nextjs-routes vv0.0.21