You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow developers to simulate APIs without requiring external tools or standalone mock servers.
Enable API Routes to function as mock services during development even when output: export is set.
Non-Goals
This feature will not address other limitations of output: export unrelated to API Routes.
It does not aim to replace existing external mock tools like MSW but to provide an additional, built-in option.
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
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