Getting started with Edge Deployments
JavaScript applications and web hosting.
Sign up at admin.freestyle.sh, create an api key, and configure it in your environment.
FREESTYLE_API_KEY=your-api-keynpm i freestyle-sandboxes@betaDeploy code
The most basic way to create a deployment is with a code snippet. Edge
deployments are compatible with node and support node modules, so you can use
popular frameworks like Express. TypeScript is also supported out of the box
with no configuration. Freestyle provides free subdomains under style.dev for
testing. To configure custom domains, see Domains.
import { freestyle } from "freestyle-sandboxes";
const { deployment, domains } = await freestyle.edge.deployments.create({
code: `
import express from 'express';
const app = express();
app.get('/', (req, res) => {
res.send('Hello from Edge Deployment!');
});
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
`,
nodeModules: {
express: "^4.18.2",
},
domains: [`${crypto.randomUUID()}.style.dev`],
});
console.log(domains);Deploy NextJS from a Git Repository
You can deploy directly from a public repository url or a freestyle repo id. See
Git for more details on repositories. Freestyle has builtin support for
builds. You can optionally provide a branch and rootPath to target specific
directories in a monorepo. By default, the deployment will not be built, so make
sure to set build: true for frameworks like NextJS that require a build step.
import { freestyle } from "freestyle-sandboxes";
const { deployment, domains } = await freestyle.edge.deployments.create({
repo: "https://github.com/freestyle-sh/freestyle-next.git", // or freestyle repo id
// branch: "main",
// rootPath: "./path/to/app",
domains: [`${crypto.randomUUID()}.style.dev`],
build: true,
});