Getting started: Global Deno apps

Table of contents

Deno is a secure runtime for JavaScript and TypeScript built with V8. This guide explains how to deploy a Deno app to Fly.

Build a Deno app

Install Deno

If you haven't installed Deno locally yet, follow the installation instructions for your operating system.

Create a server.ts file

Copy this code to a file named server.ts:

import { serve } from "";

const { PORT = "8080" } = Deno.env();

console.log("listening on", PORT);

async function helloServer(){
  for await (const req of serve(`:${PORT}`)) {
    const enc = new TextEncoder();
    const body = `Hello from Deno!`;
    req.respond({ body: enc.encode(body) });
    console.log(`${req.method} ${req.url}`)


Try running it locally with the Deno command:

deno run server.ts --allow-net --allow-env

If it's working, you should be able to open http://localhost:8080 in your browser and see a polite greeting, and the console logs will look a little like this:

listening on 8080
GET /favicon.ico
GET /another-url
GET /favicon.ico
GET /another-url/again
GET /favicon.ico

Deploy it

Get flyctl

If you're on a Mac, you can install the CLI with Homebrew:

brew install superfly/tap/flyctl

For other systems, use the install script:

curl | sh

Log in to Fly

Log in to Fly with flyctl auth login:

flyctl auth login
Opening browser to url
Waiting for session...⣽ 

This will open a browser window you can use to login. If you haven't yet registered with Fly, you can do that now!

Create a new Fly app

flyctl create --builder deno
App Name (leave blank to use an auto-generated name) deno-deno-deno

✔ New app created
  Name    = deno-deno-deno
  Owner   = deno
  Version = v0
  Status  =

Created fly.toml

This creates a fly.toml file, and sets the builder to deno. By default, this will use the latest version of Deno and try to run the file named server.ts. If you want to customize the Deno environment, you can update fly.toml:

  builder = "deno"
  entry_file = "./server.ts"
  deno_version = "v0.18.0"
flyctl deploy
Deploy source directory '.'
Docker daemon unavailable, performing remote build...
[2019-08-22T18:22:04+00:00] ✅ Successfully built fly-app
[2019-08-22T18:22:04+00:00] /bin/fly-app

==> Deploying Image
--> done
Removed deployment image:
  Version     = v0
  Reason      =
  Description =
  User        = flydev@fly.local
Build complete - succeeded

See it in action

Now try running flyctl status, you'll see output like this:

flyctl info
  Name     = deno-deno-deno                  
  Owner    = deno                            
  Version  = 5                               
  Status   = running                         
  Hostname =  

  app    tcp        80     8080            http      
  app    tcp        443    8080            tls http  

IP Addresses
  ADDRESS                                TYPE                          v4    
  2a09:8280:1:2fab:2e4e:c61b:34ac:12f0   v6

Load up in your browser and you should see your app!