For most use cases, pre-rendering your application and serving it statically is the optimal choice for running in production. This approach has the following advantages:
To prerender your application, all that is needed is to run the
factor prerender CLI command.
npx factor prerender
Running this command will build all your application files—HTML, JS, CSS, etc...—and place them in a distribution folder for serving.
If you'd like to serve your application somewhere directly after you've built it, add the
npx factor prerender --serve
You can control which port the application is served at using the
--app-port option in the command.
If you'd like to have server-oriented functionality but still host your application statically—i.e. JamStack— then you'll want to set up an "endpoint" server in production.
For a guide on deploying your endpoint server, check out the server docs.
Once you've deployed, you'll have a base URL where your server is hosted and ready to respond to endpoint requests. To let your pre-rendered site know where the endpoint server is located, you'll need to add the
FACTOR_SERVER_URL environmental variable.