Skip to content

lowlighter/vercel-deno

Repository files navigation

The Deno runtime running on Vercel.

Live demo.

✨ Features

  • Supports deno 2.x+
    • Supports local development with vercel dev
  • Seamless integration using deno standards:
  • Advanced configuration, including:
    • Deno version selection
    • Permission management
    • Environment variables
    • Assets pre-caching

❓ Frequently Asked Questions

What's the difference with vercel-community/deno?

This is a full rewrite of the unmaintained vercel-community/deno (see #159).

This implementation has been designed from the ground up to be more aligned with Deno standards. For instance, you can directly reuse code written for deno serve and handlers for Deno.serve, and it also natively supports deno shebangs, which minimizes the friction required to deploy existing Deno code to Vercel.

It also provides better support for advanced use-cases, such as specifying environment variables, pre-caching assets, or selecting the Deno version to use through pragmas, and the permissions management system is fully supported.

Why use Vercel instead of Deno Deploy?

While Deno Deploy is a great platform, Vercel free tier offers more generous limits for serverless applications.

If you are deploying a fully-fledged Deno application (which requires to be constantly running, requires storage or database, writable filesystem, etc.), Deno Deploy is likely a better fit.

If you are deploying a simple Deno application with simple functions and callbacks, then Vercel with this runtime is a great choice. Note that the free tier of Vercel limits the number of serverless function to 12.

📓 Usage

Add the following to your vercel.json file:

// vercel.json
{
  "functions": {
    "api/**/*.ts": { "runtime": "@lowlighter/[email protected]" }
  }
}

A serverless function may be defined using an export default of one of the following types:

See /api for examples.

🪛 Advanced Usage

Shebangs

Runtime options and permissions may be specified using deno shebangs.

#!/usr/bin/env -S deno run --allow-sys
export default async function serve() {
  return new Response(Deno.osRelease())
}

Important

The parser only supports shebangs that use deno run or deno serve.

Note

The --allow-read permission for the function's source file is always implicitly granted as it is required to load and run the handler. Under the hood, the handler is run within a WebWorker with the provided permissions.

Pragma

Specific instructions may be provided to the runtime using the //@vercel: pragma (which must be placed at the top of the file or immediately after the shebang).

Option Alias Description Multiple Dev Default Example
--version -v Specify the Deno version to use. latest -v 2.5.6
--env -e Specify environment variables to set. Y Y -e FOO=bar
--include -i Specify additional modules to pre-cache. Y -i /assets
  • ¹: Dev server always uses the currently installed Deno version.
  • ²: Dev server always has access to the filesystem and not a subset of it.
//@vercel: -e FOO=bar
export default async function serve() {
  return new Response(Deno.env.get("FOO"))
}

Deno in build steps

The Deno runtime is only made available by Vercel at runtime during serverless function execution.

If you wish to use it in build steps, you can use the following commands in your vercel.json:

// vercel.json
{
  "installCommand": "curl -fsSL https://deno.land/install.sh | sh",
  "buildCommand": "([ -d /vercel ] && /vercel/.deno/bin/deno task build) || true"
}

📜 License

MIT License © 2025 Lowlighter.

About

▲ Vercel Serverless Functions powered by Deno runtime !

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project