LogoFreestyle

Deploying a Website

How to deploy a website you didn't write with Freestyle

Install the Freestyle Sandboxes package

npm i freestyle-sandboxes

Get your API key

Go to the Freestyle Dashboard and get your API key

Get the website code ready

# Clone our example repo
git clone https://github.com/freestyle-sh/sandbox_sdks/

The website code is located at examples/deploy-api-human/test-sites/simple in this repo.

Deploy the website

Create a deploy.js file in the root of the repo with the following code:

deploy.js
import { FreestyleSandboxes } from "freestyle-sandboxes";
import { prepareDirForDeploymentSync } from "freestyle-sandboxes/utils";
 
const api = new FreestyleSandboxes({
  apiKey: process.env.FREESTYLE_API_KEY!, // make sure to set this
});
 
const files = prepareDirForDeploymentSync(
  "examples/deploy-api-human/test-sites/simple"
);
api
  .deployWeb(files, {
    domains: ["yourtestdomain.style.dev"],
    entrypoint: "index.ts",
  })
  .then((result) => {
    console.log("Deployed website @ ", result.domains);
  });

Then run the file to deploy the website:

node deploy.js

Next Steps

  • If you want to deploy to custom domain, first you need to verify a domain

On this page