Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate hook to wrap each route #173

Open
eddiesholl opened this issue Oct 13, 2023 · 2 comments
Open

Generate hook to wrap each route #173

eddiesholl opened this issue Oct 13, 2023 · 2 comments

Comments

@eddiesholl
Copy link

We've recently grabbed this library to bring some type safety to a next app with many heavily nested routes. The improvement is awesome.

I'm wondering if there's any thought of extending the code generation to include a hook for each route. It is quite noisy to have to build up a path target from scratch every time, unpacking props from useRouter, and attaching them to a long string that has to be just right. Of course it's much better doing this now with some type safety.

I could have worn I saw a question like this on this repo (or maybe elsewhere) a few weeks back, but couldn't find it again.

Cheers!

@tatethurston
Copy link
Owner

Hey @eddiesholl I'm happy to consider a PR or a design for this. I've thought about code generation for runtime utilities like this in the past -- the main pieces would be allowing users to opt-in and determining where to place the generated code.

Could you share an example of the route hook you have in mind?

I think the closest question I've seen to something like this is #39.

@eddiesholl
Copy link
Author

Cheers, yes I had read through that one and realised that could factor into something like this. I'll see if I can propose something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants