Deploying Static Assets
How to deploy a static bundle to Freestyle
Deploying static assets can be useful for hosting websites, or static files in general. Freestyle lets you host them with all our support for custom domains, certificates, and analytics.
Deploying Static Assets
All deploys on Freestyle are servers, so to host the static assets you need to create a simple server that serves them. You can do this with any server you like, but we recommend hono for its simplicity and speed.
To set it up, first, you need to install the hono package:
Then, you can create a simple server that serves the static assets. Here is a simple example that serves the files in a static
folder, and falls back to static/index.html
for any requests that don't match a file:
Deploying to Freestyle
Via the SDK
First, you can get your API Key from the Freestyle Dashboard.
Then, you need to install the Freestyle SDK:
Then you can create an instance of the client in your code:
Then, you can deploy your app with the following code:
This will upload everything in your current directory to Freestyle, and deploy it as a web server.
You can use the prepareDirForDeploymentSync
function to prepare the
directory for deployment. This will copy all the files in the current
directory to a temporary directory, and return the path to that directory. You
can also refer to the API Reference for constructing the deployment object
yourself, or deploying through a Tar or Git Repository.
Via the CLI
First, you need to install the Freestyle CLI:
Then, you need to login to your Freestyle account:
Then, you can deploy your app with the following command:
This will upload everything in your current directory to Freestyle, and deploy it as a web server.
Next Steps
Now that you can deploy static assets, you'll likely want to set up a custom domain for your server. You can do this by following the Custom Domains guide.