Is it possible to use api folder outside of app folder?
Unanswered
American black bear posted this in #help-forum
American black bearOP
I saw this
https://nextjs.org/docs/app/building-your-application/routing/colocation#store-project-files-outside-of-app
1. Is there a way of using the api folder outside of the app folder, like mentioned in the url above?
2. Does this mean this way the app folder contains backend components only? I want to make sure I have distinction between the frontend and backend, to understand the framework and my project better.
https://nextjs.org/docs/app/building-your-application/routing/colocation#store-project-files-outside-of-app
1. Is there a way of using the api folder outside of the app folder, like mentioned in the url above?
2. Does this mean this way the app folder contains backend components only? I want to make sure I have distinction between the frontend and backend, to understand the framework and my project better.
1 Reply
you need to create the routes inside the
you can have both server and client components in the
app folder, this includes pages (page.tsx) and route handlers (route.ts). you can store the rest of the files anywhere else you want, you just need to import the functions into the route filesyou can have both server and client components in the
app folder, it has no restrictions