LogoFreestyle

Deploying a Website

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

The Freestyle Web API provides a set of tools to build, deploy and manage websites.

This guide will go through the fastest path to deploy a sample website on Freestyle using our SDKs.

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}"
)

When deploying a website to Freestyle, there are two distinct parameters:

  • Source: This is the code you want to deploy, it can be a Git repository, a set of files, or a link to a tarball. In this example, we're using a public Github repository that contains a Next.js App.
  • Configuration: This is the configuration for the deployment, it can include the domains you want to deploy to, the entrypoint of the application, whether to build the code or deploy it as is, timeout behavior and much more. We set build: true to automatically detect the framework and build the code.

Then run the file to deploy the website:

node deploy.js
python deploy.py

Next Steps

Freestyle AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details with the official documentation.

How can I help?

Ask me about Freestyle while you browse the docs.