Best practice to create nextjs plugin
Unanswered
Bumblebee Hummingbird posted this in #help-forum
Bumblebee HummingbirdOP
I have a specific part of my app (which include a page and an API route) which I would like to reuse in other projects. Currently the package exposes a Page component and a file which exports all api routes. The problem is that the user still needs to manually create the correct folders and base
Here is the required code for the page:
And there is the api routes:
I was looking for a better developer experience where he could just sort of plug and play some piece of logic like this
page.tsx together with route.tsx. Here is the required code for the page:
// app/access/page.tsx
import { Page as AccessAuthPage } from "@custom/access"
export default function Page() {
return <AccessAuthPage />
}And there is the api routes:
// app/access/route.tsx
import * as routes from "@custom/access"
export async function POST(request: Request) {
return routes.POST(request)
}I was looking for a better developer experience where he could just sort of plug and play some piece of logic like this