Deploying Vite Projects with SSR
How to add SSR to a Vite project to Freestyle
Setup
When you're setting up a Vite project for SSR, use the vite-extra
CLI to give you all the parts you need for SSR.
This will create a Vite project with the extra configuration you need for SSR like separate server and client entrypoints. For more information check out Vite's Official SSR Documentation
Custom Configuration
This template comes with the infrastructure for SSR, but you have to add a server to handle it. On Freestyle, we recommend using hono
for this. We recommend adding index.js
and installing hono
as a dependency.
Then create a file called index.js
in the root of your project. This file will be the entrypoint for your server.
Deploying the App
CLI
Install the Freestyle CLI.
Now deploy it
API
You can also deploy the app using the API.
Install the Freestyle API client.
Then you can use the following code to deploy the app:
Finally, to make the deploy happen, run it
Next Steps
- Now that you can deploy Vite apps to Freestyle, you'll probably want to deploy them to custom domains. To deploy to your own custom domains, you can use the UI in the Freestyle dashboard, and to start building self serve to deploy to your users domains you should check out this guide