LogoFreestyle

Deploying a Website

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

This guide will go through how to deploy a sample website on Freestyle using our JavaScript SDK.

Install the Freestyle Sandboxes package

First, install the package with your preferred package manager

npm i freestyle-sandboxes
pnpm i freestyle-sandboxes
bun i freestyle-sandboxes
yarn add freestyle-sandboxes
pip install freestyle

Get your API key

Go to the Freestyle Dashboard and get your API key

Deploy the website

Create a deploy script in the root of the repo with the following code:

import { FreestyleSandboxes } from "freestyle-sandboxes";

const api = new FreestyleSandboxes({
  apiKey: process.env.FREESTYLE_API_KEY!, // make sure to set this
});

api
  .deployWeb(
    {
      kind: "git",
      url: "https://github.com/freestyle-sh/freestyle-base-nextjs-shadcn", // URL of the repository you want to deploy
    },
    {
      domains: ["yourtestdomain.style.dev"],
      build: true, // automatically detects the framework and builds the code
    }
  )
  .then((result) => {
    console.log("Deployed website @ ", result.domains);
  });
import freestyle

client = freestyle.Freestyle("YOUR_FREESTYLE_API_KEY")

response = client.deploy_web(
    src=freestyle.DeploymentSource.from_dict(
    {
        "kind": "git",
        "url": "https://github.com/freestyle-sh/freestyle-base-nextjs-shadcn",
    }
    ),
    config=freestyle.FreestyleDeployWebConfiguration(
        domains=["welcomepython.style.dev"],
        build=freestyle.DeploymentBuildOptions.from_dict(True),
    ),
)


print(
    f"Deployed website @ {response.domains}"
)

Then run the file to deploy the website:

node deploy.js
python deploy.py

Next Steps

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