I'm working on a project where they chose to use nextJS as a client side tool, but I want to deploy the client as static code somewhere else.
Doing a build creates a folder with all the nextJS proprietary server stuff.
Is there a way to make a normal build to just static react files? I don't want SSR or any of their EEE stuff.
I know Vercel is a VC backed mousetrap, so it's not really in their interest to make it easy to extract yourself, but hoping we don't have to rebuild the site to get out of this.
I'm working on a project where they chose to use nextJS as a client side tool, but I want to deploy the client as static code somewhere else.
Doing a build creates a folder with all the nextJS proprietary server stuff.
Is there a way to make a normal build to just static react files? I don't want SSR or any of their EEE stuff.
I know Vercel is a VC backed mousetrap, so it's not really in their interest to make it easy to extract yourself, but hoping we don't have to rebuild the site to get out of this.
Share Improve this question asked Oct 4, 2022 at 19:19 dcsandcsan 12.3k17 gold badges92 silver badges139 bronze badges2 Answers
Reset to default 4Update your build script in package.json
to use next export
:
"scripts": {
"build": "next build && next export"
}
Note: this feature does not support the following:
- Image Optimization (default loader)
- Internationalized Routing
- API Routes
- Rewrites
- Redirects
- Headers
- Middleware
- Incremental Static Regeneration
fallback: true
getServerSideProps
If you are using any of the features listed above, you will have to stick to prerendering individual pages, which Next automatically does for you.
Source: Docs
UPDATE February 2024: the configuration to for static exports has changed, slightly. Refer to the latest Next.js docs for details.
Sounds like you are looking for the next export
. Should do just that, but there are some limitations. Documentation is here: https://nextjs/docs/advanced-features/static-html-export