Quickstart
Follow the steps in this Quickstart guide to get up and running with Akamai Functions in less than two minutes. Akamai Functions is the platform for running Spin applications on Akamai Cloud.
To complete this tutorial you need access to the public preview of Akamai Functions. If you haven’t already requested access, please complete this form. The Akamai Functions team will review your request and follow up shortly.
Install Spin
Spin is an open-source project you can use to build, run, and deploy Spin applications. It's both a CLI tool and a runtime. It provides SDKs for a variety of programming languages, including, but not limited to, Rust, Go, JavaScript and TypeScript.
Linux
The Spin project provides installers that are supported on Linux (amd64).
- Download the
spinbinary using theinstall.shscript hosted on this site.
curl -fsSL <https://developer.fermyon.com/downloads/fwf_install.sh> | bash
- Then move the
spinbinary somewhere in your path, so you can run it from anywhere. For example:
sudo mv ./spin /usr/local/bin/spin
To find the Spin version installed on your machine run, spin --version.
Install the aka plugin for Spin
aka plugin for SpinTo interact with Akamai Functions, you need to install the Akamai Functions for Akamai Spin plugin, aka. Use this command to install the plugin.
spin plugin install akaIf you’ve previously installed the aka plugin, take a moment to upgrade it to ensure compatibility with the latest features and fixes.
spin plugins update
spin plugins upgrade akaYou can learn more about managing Spin plugins in this article.
Go to the aka spin command reference for a complete list of supported commands.
Install language specific tooling
With Spin you can build applications using a wide variety of different programming languages. This quickstart, contains instructions and samples for JavaScript, TypeScript and Rust.
Follow these instructions to install language specific tooling on your machine.
Go to, WebAssembly language support matrix for more information about the supported languages.
JavaScript
To build Spin apps with JavaScript, you need Node.js installed on your system. Head over to https://nodejs.org/en/download, to download Node.js.
Once Node.js is installed on your machine, you can check its version using the following command.
node --version
v22.13.0
We recommend Node.js version 22 (or newer).
Create a new Spin application
Next we’ll prepare an application with Spin. There are code samples below for you to use, but you can write an app from scratch or use an existing template. The Spin Hub has many reference examples and templates. You can also find several code samples, sorted by use case in the Akamai Functions GitHub repo.
JavaScript
spin new -t http-js --accept-defaults hello-spin
The http-js template creates the application boilerplate for you. Once it's finished, change to the application directory (hello-spin).
cd hello-spin
From within the application directory, install the necessary dependencies using your package manager of choice (we'll use npm here).
npm install
The http-js template generates an idiomatic JavaScript application. Take a few seconds and explore the source code generated by the template in src/index.js.
// For AutoRouter documentation refer to <https://itty.dev/itty-router/routers/autorouter>
import { AutoRouter } from 'itty-router';
let router = AutoRouter();
// Route ordering matters, the first route that matches will be used
// Any route that does not return will be treated as a middleware
// Any unmatched route will return a 404
router
.get("/", () => new Response("hello universe"))
.get('/hello/:name', ({ name }) => `Hello, ${name}!`)
addEventListener('fetch', async (event) => {
event.respondWith(router.fetch(event.request));
});
Compile the application
Use the spin build command to compile your Spin app to WebAssembly.
spin buildBuilding component hello-spin with `npm run build`
> hello-spin@1.0.0 build
> npx webpack --mode=production && npx mkdirp target && npx j2w -i dist.js -d combined-wit -n combined -o target/hello-spin.wasm
asset dist.js 5.93 KiB [compared for emit] [javascript module] (name: main)
orphan modules 25.5 KiB [orphan] 25 modules
./src/spin.js + 2 modules 5.95 KiB [built] [code generated]
webpack 5.97.1 compiled successfully in 66 ms
Using user provided wit in: combined-wit
Successfully written component
Finished building all Spin components
Test the application locally
You can test your Spin apps on your local computer by using the spin up command anytime. The spin up command starts an HTTP server on your local machine (port 3000 by default) and instantiates and invokes your Spin application for every request sent to the endpoint.
spin upLogging component stdio to ".spin/logs/"
Serving <http://0.0.0.0:3000>
Available Routes:
hello-spin: <http://0.0.0.0:3000> (wildcard)If port
3000is already in use, you could set a different port by specifying the--listenflag. For example,spin up --listen 127.0.0.1:3001.
From within an separate terminal instance, you can use a tool like curl to send an HTTP request to your Spin app
curl -i http://localhost:3000/HTTP/1.1 200 OK
content-length: 14
content-type: text/plain;charset=UTF-8
date: Tue, 14 Jan 2025 16:10:36 GMT
Hello, FermyonYou can terminate spin up at anytime, by pressing CTRL+C.
Log in to Akamai Functions
To log in you need access to the public preview of Akamai Functions. If you haven’t already, please complete the Onboarding form. Akamai Functions supports two identity providers, Akamai Control Center and GitHub. If you have an Akamai Control Center account, you can log in using your user ID and password. Otherwise, you need to use GitHub. If both accounts share the same email address, they are automatically cross-linked.
The Akamai Functions team will review your onboarding request and follow up shortly.
Before you log in using your Akamai Control Center or GitHub account information make sure that you complete the following tasks.
- Install the
akaplugin for Spin.- Receive the allow-listing status for Akamai Functions.
- Request and receive access to the public preview.
- Run the
spin aka logincommand.
spin aka login- Click the link displayed in the output from the
spin aka logincommand.
Go to <https://login.infra.fermyon.tech/realms/neutrino/device?user_code=BB-AA>
and follow the prompts.
Don't worry, we'll wait here for you. You got this.- Authenticate using your Akamai Control Center credentials or your individual GitHub account.
- Once you're logged in you need to authorize the
spinCLI to interact with your Akamai Functions account.
Deploy the application
You can use the spin aka deploy command to deploy the application to Akamai Functions.
spin aka deployThe spin command runs using the Spin binary in your system path. It reads the Spin application definition file spin.toml in the current (hello-spin) directory to know what application to deploy. It will ask you for a name for the application and then it will ask for confirmation that you want to deploy.
Here's an example of a successful Spin application deployment on Akamai Functions.
Name of new app: hello-spin
Creating new app hello-spin in account your-account
Note: If you would instead like to deploy to an existing app, cancel this deploy and link this workspace to the app with `spin aka app link`
OK to continue? yes
Workspace linked to app hello-spin
Waiting for app to be ready... ready
App Routes:
- hello-spin: https://ec8a19d8-6d10-4056-bb69-cc864306b489.fwf.app (wildcard)You can CTRL+Click on the link in the terminal window to visit the web application you just deployed.
Congratulations, you’ve now deployed your first Spin application to Akamai Functions!
Updated 2 days ago
