In SSG mode using API Routes as mock #74232
Clover-You
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Goals
output: export
is set.Non-Goals
Background
In a frontend-backend decoupled development workflow, frontend teams often need to simulate APIs before the backend is fully implemented to ensure development progress and test frontend functionality. Mock services become an indispensable tool in this process.
Next.js API Routes offer a simple yet powerful server-side functionality, making them theoretically well-suited for mock services. However, they are incompatible with
output: export
, forcing developers to rely on external tools like MSW or set up standalone mock services to overcome this limitation.Proposal
I believe this can be implemented by validating the output configuration during the build process. If output: export is set, we can skip certain handling of API Routes during the build. Of course, it might not be as straightforward as I imagine.
If possible, I would like to contribute to this feature, but my current technical expertise makes it challenging, and I am not very familiar with the underlying implementation details of NextJS.
Beta Was this translation helpful? Give feedback.
All reactions