Next.js Discord

Discord Forum

Stupid Question about Externally Provided Routes...

Unanswered
Brambling posted this in #help-forum
Open in Discord
Avatar
BramblingOP
So the stupid question is it even possible? I have an auth library that needs to have some api routes as well as the login and logout page... i want to use this on multiple projects thus the external library... is this even possible?

3 Replies

Avatar
You can do it like next-auth does, have the lib users make dynamic routes like api/auth/[…yourLib]/route.ts and import the library code in that route
Avatar
BramblingOP
That is a great idea on the basic api routes but is there a way to build re-usable pages that can be ported between apps easily?
Avatar
you have to do the same thing. app/[...yourLib]/page.tsx.

next-auth also does it but it doesn't require a page.tsx file because the pages it provides are returned as html responses and not part of the app's react tree