Next.js
Last updated
Last updated
EarthFast supports SSR Next.js projects by running bundles inside docker containers. Builds are created and run consistent with Next.js best practices for self hosting (as per their ) and all features are supported, including image optimization, middleware, SSR etc. Static export projects run as shown in the Architecture page.
In the Next.js architecture, and are still utilized but in slightly different ways when a project uses Next.js. Given the server side nature of Next.js, a service worker isn't utilized, so the Domain Node serves as a proxy and now does the same validation the service worker would do in a fully static site.
Each content node associated with the project will run the same Next.js bundle and the Domain Node will act as the proxy between all the content nodes and do all validation. The validation includes checking the hash of files returned by the content nodes and making sure it's consistent with the manifest and randomizing node requests to ensure compliance and safety.
EarthFast is also potentially more secure than other self-hosted Next.js alternatives because all static files are still hashed with a global manifest. This means there's still tamper resistance while running the bundles and requests to fetch these assets are randomized across multiple nodes. However, it's less secure than a fully browser based service worker making requests directly to static file servers. If security is your concern, it's recommend to use Next.js with static export or a fully front end framework.
Why do you need the domain node to proxy requests from the browser to content nodes?
A project can have multiple content nodes and for certain features to work, like cookies, there needs to be a consistent domain and the domain node provides that.
Is there a specific version of Next.js I need to run?
No, the bundle generated uses the option which includes all dependencies including the Next.js executable into the bundle
How do I build a Next.js project for EarthFast?
If you use the dashboard and connect a GitHub repo or url, our CI process builds your bundle for you. If you're manually uploading via the dashboard or the CLI, you will have to build the bundle yourself.
This will create a folder at
.next/standalone
which can then be deployed on its own without installingnode_modules
.Additionally, a minimal
server.js
file is also output which can be used instead ofnext start
. This minimal server does not copy thepublic
or.next/static
folders by default as these should ideally be handled by a CDN instead, although these folders can be copied to thestandalone/public
andstandalone/.next/static
folders manually, after whichserver.js
file will serve these automatically.
The bundles are generated the same way whether generated manually or using the CI build system. EarthFast supports standalone output bundles, instructions are and the relevant section from the docs below
Note - you must copy the public
and .next/static
folders into the standalone/
folder. You can then upload standalone/
to the dashboard if create a project of type manual, or if using the CLI, generate the bundle and checksum by following .