---
title: Getting started with Compute
summary: Experiment with Fastly's edge computing platform.
url: >-
  https://www.fastly.com/documentation/guides/compute/getting-started-with-compute
---

The Fastly Compute platform is an advanced edge computing system that runs your code, in your favorite language, on our global [edge network](https://www.fastly.com/network-map). Security and portability are provided by compiling your code to [WebAssembly](https://webassembly.org/). We run your code using [Wasmtime](https://wasmtime.dev/).

With the Compute platform you have access to Fastly edge primitives like data stores, dynamic configuration, and real-time messaging. The platform is completely language agnostic at every layer of the stack, and you can include dependencies from your preferred package registry.

Whether it's authentication, personalization, geofencing, SEO, observability, templating, APIs, or even your entire application, whatever you can conceive, you can probably run on the Compute platform.

## Getting started

To use the Compute platform, you must [create a Fastly account](https://www.fastly.com/signup) if you don't already have one.

### Generate an API token

To authenticate the [Fastly CLI](https://github.com/fastly/cli), [create an API token](https://www.fastly.com/documentation/reference/api#authentication) for your account. Make sure the token has a `global` scope, and make a note of the token.

### Set up the development environment

[Install the Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli#installing), and then verify that everything works by running <kbd>fastly version</kbd>. For example:

```term
$ fastly version
Fastly CLI version vX.Y.Z (abc0001)
Built with go version go1.20.1 linux/amd64
```

Configure the CLI to act on your behalf using the API token you created:

```term
$ fastly profile create
```

This will store your API token credential in a configuration file and remember it for subsequent commands. There are [other ways of authenticating the CLI](https://www.fastly.com/documentation/reference/tools/cli/#configuring) if you prefer.

### Choose a language to use

We provide SDKs for multiple languages that can compile to Compute-compatible WebAssembly packages. Here is a comparison of SDK-exposed features that can differ among languages:

> **HINT:** This table only covers features exposed to your code. You may also be interested in [how the Compute platform compares to VCL](https://www.fastly.com/documentation/guides/).

> **NOTE:** This page contains a language/SDK compatibility matrix. Visit the URL to see the full table.

We recommend the use of official Fastly SDKs (available for [Rust](https://www.fastly.com/documentation/solutions/starters/compute-starter-kit-rust-default/), [JavaScript](https://www.fastly.com/documentation/solutions/starters/compute-starter-kit-javascript-default/), [Go](https://www.fastly.com/documentation/solutions/starters/compute-starter-kit-go-default/), and [C++](https://www.fastly.com/documentation/solutions/starters/compute-starter-kit-cpp-default/)), but you can also create your own for a language of your choice, or use a community-created SDK. [Learn more about custom SDKs](https://www.fastly.com/documentation/guides/compute/developer-guides/custom/).

### Install language tooling

To build your project, the Fastly CLI requires your local toolchain to be available and up to date. To install the toolchain for your chosen language, follow these instructions:

### Rust

Compiling Rust applications for the Compute platform requires that
  you have `rustup` installed. If you don't have `rustup` installed, download and install `rustup`:

```term
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
```

  `rustup` itself will ensure that the necessary toolchain and components are installed by using the contents of the `rust-toolchain.toml` file in the Compute project, whenever any `cargo` command is executed.

  As new versions of Rust are released, consult the [Rust on the Compute platform](https://www.fastly.com/documentation/guides/compute/developer-guides/rust) page to determine whether those versions are compatible with the Compute platform.

### Javascript

Compiling JavaScript applications for the Compute platform requires a recent version of [Node.js](https://nodejs.org/) (>= 16.6). Before building the app, you also need to be able to install dependencies using the [`npm` package manager](https://www.npmjs.com/) or an alternative.

### Go

Compiling Go applications for the Compute platform requires [Go](https://go.dev/doc/install) 1.21 or higher, or [TinyGo](https://tinygo.org) 0.28.1 or higher.

### Cpp

In order to develop for Fastly Compute in C++, obtain the following tools for your platform:

- [CMake 3.x](https://cmake.org/download/#legacy) 3.25 or newer, not compatible with CMake 4
- [GNU make](https://www.gnu.org/software/make/)
- [WASI SDK](https://github.com/webassembly/wasi-sdk/releases) 25.0 or newer
- [Fastly CLI](https://www.fastly.com/documentation/reference/tools/cli/) 14.0 or newer

It is recommended that `cmake`, `make`, and `fastly` be available on the system path, and that the WASI SDK be made available at `/opt/wasi-sdk`.

> **HINT:** For best results, download the `wasi-sdk-<version>.tar.gz` for your platform and expand it to `/opt/`. Then, create a symbolic link so your projects can use a consistent path regardless of version updates.
>
> For example, on macOS (Apple Silicon):
>
> ```bash
> sudo ln -s /opt/wasi-sdk-32.0-arm64-macos /opt/wasi-sdk
> ```

For running unit tests, also obtain [Viceroy](https://github.com/fastly/Viceroy/tree/main) (0.15.0 or newer) and place it on the system path.

### Create a new project

### Rust

To create a Compute application in Rust, follow the steps listed below for initializing a Compute application.

### Javascript

To create a Compute application in JavaScript or TypeScript, use npm with the `@fastly/compute` initializer to interactively initialize your application.

```term
$ mkdir example && cd example
$ npm create @fastly/compute
```

  Follow the prompts to configure your new project. A local development environment and a [fastly.toml](https://www.fastly.com/documentation/reference/compute/fastly-toml) package manifest will be generated based on your selections.

```term
┌  @fastly/create-compute
│
●  Use `npm create @fastly/compute -- --help` for options
│
●  Found Fastly CLI v10.15.0
│
◇   ──────────────────────────────────╮
│                                     │
│  Using directory: /path/to/example  │
│                                     │
├─────────────────────────────────────╯
│
◇   ──────────────────────────╮
│                             │
│  Using empty authors list.  │
│                             │
├─────────────────────────────╯
│
◇  Select a language for your Compute application, or specify a starter kit.
│  JavaScript
│
◇  Select a starter kit
│  [default] A simple Fastly starter kit for JavaScript
│
◇  Confirm creation of Compute application with above options.
│  Yes
│
◇  Application created and initialized!
│
◆  Application created at: /path/to/example
│
└  Process completed!
```

> **HINT:** See the `@fastly/create-compute` initializer's [reference page](https://www.npmjs.com/package/@fastly/create-compute) for full options (e.g., if you want to use a directory other than the current one).

  Alternatively, follow the general steps listed below for initializing a Compute application.

### Go

To create a Compute application in Go, follow the steps listed below for initializing a Compute application.

### Cpp

To create a Compute application in C++, follow the steps listed below for initializing a Compute application.

Type <kbd>fastly compute init</kbd> to scaffold a new Fastly Compute project. The CLI will generate source code for your project in the current working directory.

You will be asked to choose a language and then a starter kit to use as the starting point for your project. There are many [starter kits available](https://www.fastly.com/documentation/solutions/starters). If this is your first project, we recommend choosing the default starter for your chosen language.

```term
$ mkdir example && cd example
$ fastly compute init
```

Follow the prompts to configure your new project:

```term
Creating a new Fastly Compute project.

Press ^C at any time to quit.

✓ Validating directory permissions

Name: [example]
Description: My new Rust-based app!
Author (email): jo.test@example.com
Language:
[1] Rust
[2] JavaScript
[3] Go
[5] Other ('bring your own' Wasm binary)
Choose option: [1] 1
Starter kit:
[1] Default starter for Rust
    A basic starter kit that demonstrates routing, simple synthetic responses and
    overriding caching rules.
    https://github.com/fastly/compute-starter-kit-rust-default
[2] Empty starter for Rust
    An empty starter kit project template.
    https://github.com/fastly/compute-starter-kit-rust-empty
...

Choose option or paste git URL: [1]
```

At the prompts, provide details about the service you're creating:

- **Name**: Enter a name for your service. By default, the CLI uses the name of the current directory.
- **Description**: Optionally enter a short description for your service, or leave it blank.
- **Author**: Enter an email address or accept the default, which is the email associated with your API token.
- **Language**: Select the language you want to use to write your code.
- **Starter kit**: Choose from the available [starter kits](https://www.fastly.com/documentation/solutions/starters) or press enter to accept the default. You can also enter the URL of a GitHub repository to use a compatible template that's not in the list of starter kits.

A local development environment and a [fastly.toml](https://www.fastly.com/documentation/reference/compute/fastly-toml) package manifest will be generated based on your selections:

```term
✓ Fetching package template
✓ Reading package manifest
✓ Setting package name in manifest to "example"
✓ Setting description in manifest
✓ Setting authors in manifest to 'jo.example@example.com'
✓ Setting language in manifest to 'rust'
✓ Saving manifest changes
✓ Initializing package

Initialized package example to:
	/home/jo/repos/example

To publish the package (build and deploy), run:
	fastly compute publish

SUCCESS: Initialized package example
```

> **HINT:** See the <kbd>fastly compute init</kbd> command's reference page for full options (e.g., if you want to use a directory other than the current one).

### Compile to WebAssembly

You already have a complete, functional Compute project at this point. A default starter kit will run fine without any code changes, but if you want to dive in to the code right now, check out the language-specific guides on [Rust](https://www.fastly.com/documentation/guides/compute/developer-guides/rust), [JavaScript](https://www.fastly.com/documentation/guides/compute/developer-guides/javascript), [Go](https://www.fastly.com/documentation/guides/compute/developer-guides/go), or [C++](https://www.fastly.com/documentation/guides/compute/developer-guides/cpp).

To run the Compute project on Fastly, it needs to be compiled into a WebAssembly module that can be packaged for Fastly use. The CLI runs the appropriate compiler for the language you're using by executing the `scripts.build` command defined in your project's [fastly.toml](https://www.fastly.com/documentation/reference/compute/fastly-toml) file, and generates the necessary WebAssembly binary.

> **IMPORTANT:** The default [fastly.toml](https://www.fastly.com/documentation/reference/compute/fastly-toml) build command for JavaScript _assumes dependencies are already installed_. To make sure this is done, run the dependency manager of your choice to install the dependencies listed in `package.json`. For example, `npm` or `yarn`:
>
> ```term
> $ npm install
> ```
>
> The compilers for Rust and Go automatically resolve and install dependencies, so those will usually be taken care of when you run `fastly compute build`.

Type <kbd>fastly compute build</kbd> when you're ready to build:

```term
$ fastly compute build
✓ Verifying package manifest
✓ Identifying package name
✓ Identifying toolchain
✓ Running [scripts.build]
✓ Creating package archive

SUCCESS: Built package (pkg/<name>.tar.gz)
```

### Deploy to a Fastly service

To deploy the project to Fastly, run <kbd>fastly compute deploy</kbd>.

> **IMPORTANT:** Deploying your first Compute project will start a Compute free trial. While on a free trial, Compute services in your account are subject to [lower limits](https://www.fastly.com/documentation/guides/compute/getting-started-with-compute#limitations-and-constraints) and cannot be used for production traffic. When you're ready to use your Compute service for production traffic, [contact our sales team](mailto:sales@fastly.com) or your Fastly account contact.

If you already have a Fastly service you want to deploy the package to you can add the service ID into the `service_id` property in [fastly.toml](https://www.fastly.com/documentation/reference/compute/fastly-toml) before running the <kbd>deploy</kbd> command; otherwise the CLI will lead you through creation of a service automatically.

```term
$ fastly compute deploy

There is no Fastly service associated with this package. To connect to an existing service
add the Service ID to the fastly.toml file, otherwise follow the prompts to create a
service now.

Create new service: [y/N] y

Service name: [example]

✓ Creating service

Domain: [random-funky-words.edgecompute.app]

Backend (hostname or IP address, or leave blank to stop adding backends):

✓ Creating domain 'random-funky-words.edgecompute.app'
✓ Uploading package
✓ Activating service (version 1)
✓ Checking service availability (status: 200)

Manage this service at:
	https://manage.fastly.com/configure/services/PS1Z4isxPaoZGVKVdv0eY

View this service at:
	https://random-funky-words.edgecompute.app

SUCCESS: Deployed package (service PS1Z4isxPaoZGVKVdv0eY, version 1)
```

At the prompts, provide details about the service you're creating:

- **Domains**: Press enter to accept the [automatically generated domain name](https://www.fastly.com/documentation/guides/concepts/routing-traffic-to-fastly/#fastly-assigned-domains). We'll take care of the TLS and DNS and give you a working domain immediately. It's a good idea to accept the default now and add more domains to the service later.
- **Backends**: If you want to configure an origin server for your service, enter a valid hostname, or an IPv4 or IPv6 address. Alternatively, leave the prompt blank to create a service with no origin server. Such services cannot forward requests to your servers, but they can respond to client requests with a response composed within your Compute package.

The output includes a link to manage your service in the Fastly web interface. You can use this link to perform more complex configuration of the service, such as adding or removing domains, changing origin server settings, and setting up logging endpoints.

> **HINT:** Once you've done a few deploys, you might want to start [using orchestration tools like Terraform](https://www.fastly.com/documentation/guides/integrations/non-fastly-services/developer-guide-terraform/) to manage your Fastly service configurations.

After the command completes, it may take up to a minute before the new service begins handling requests, and if you're replacing a previous version of the package, the earlier version may continue to handle requests for that period.

### Test and celebrate

Open a browser and head over to the domain that was assigned to the service, such as `random-funky-words.edgecompute.app`, and you should see a working site. If you used the default starter kit, it will look something like this:

![Compute welcome content](/img/success-precomposed.png)

### Add your own domain

Now that your working project is deployed, you may want to assign a domain name to it. We have a lot of [TLS options](https://www.fastly.com/documentation/guides/concepts/routing-traffic-to-fastly). As a starting point, it's a good idea to create a **TLS Subscription** so that Fastly will generate a certificate for you.

- [Setting up a custom domain with a TLS subscription](https://www.fastly.com/documentation/guides/concepts/#setting-up-a-domain).

## Go further

If you would like to **learn** more about how the Compute platform integrates with your preferred language, read our getting started guides for each of our officially supported languages:

- [Using Rust](https://www.fastly.com/documentation/guides/compute/developer-guides/rust)
- [Using JavaScript](https://www.fastly.com/documentation/guides/compute/developer-guides/javascript)
- [Using Go](https://www.fastly.com/documentation/guides/compute/developer-guides/go)
- [Using C++](https://www.fastly.com/documentation/guides/compute/developer-guides/cpp)

If you are already familiar with [VCL](https://www.fastly.com/documentation/guides/full-site-delivery/fastly-vcl) and want to **migrate** an existing VCL service to the Compute platform, try the [VCL to Compute migration guide](https://www.fastly.com/documentation/guides/compute/developer-guides/migrate), which shows examples of the most common use cases in VCL and how to implement the same functionality using the Compute platform's supported languages.

Or maybe you have an idea in mind and want to **experiment** with examples? Try cloning a [starter kit](https://www.fastly.com/documentation/solutions/starters), copy and pasting code from our [code examples](https://www.fastly.com/documentation/solutions/examples), or following a [tutorial](https://www.fastly.com/documentation/solutions/tutorials).

## Execution lifecycle

Compute runs request handlers in WebAssembly sandboxes. In the default configuration, each request starts a new sandbox, providing fast startup and per-request isolation.

Compute also supports [reusable sandboxes](https://www.fastly.com/documentation/guides/compute/developer-guides/sandbox-lifecycle/), an opt-in mode in which a sandbox may process multiple requests to reduce repeated initialization overhead.

## Limitations and constraints

### Secure connections only

Compute services accept client connections on port 443 only. This is different from VCL services, which support client connections on port 80.

> **HINT:** If your Compute service receives a request on port 80, Fastly automatically returns a `308` ("Permanent Redirect") response status with the `Location` header indicating the HTTPS version of the same URL in a `Location` header.

### Resource limits

Compute services are subject to [Compute resource limits](https://docs.fastly.com/products/compute-resource-limits). If you need to exceed any limits, contact your Fastly account manager or [Fastly support](https://support.fastly.com/).

> **IMPORTANT:** Compute services are also affected by limits that apply to products or platform services that you access through your application code. Refer to their own documentation for information on how those limits might interact with your application:
>
> - [Fastly cache](https://www.fastly.com/documentation/guides/concepts/cache/#limitations-and-constraints)
> - [Service chaining](https://www.fastly.com/documentation/guides/getting-started/services/service-chaining#loop-detection)
> - [Image Optimizer](https://www.fastly.com/documentation/reference/io/#compute-platform-limitations)
