All skills
denoland avatar

/deno-deploy

@2311d69 official
by Denodenoland/skills99 stars
8

Use when deploying Deno apps to production, asking about Deno Deploy, or working with `deno deploy` CLI commands. Covers deployment workflows, environment variables, KV database access, custom domains, the --tunnel flag for local development, and the `deno deploy` command reference.

Use this Skill: https://skilld.dev/gh/denoland/skills/deno-deploy

This session only. Nothing lands on disk.

referencesDENO_KV.md

≈862 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Deno KV

What is Deno KV?

Deno KV is a key-value database built into Deno. On Deno Deploy, it's a fast, globally distributed store that requires no setup or configuration.

Quick Start

// Open the KV store (auto-connects on Deno Deploy)
const kv = await Deno.openKv();

// Store a value
await kv.set(["users", "alice"], { name: "Alice", email: "alice@example.com" });

// Retrieve a value
const result = await kv.get(["users", "alice"]);
console.log(result.value); // { name: "Alice", email: "alice@example.com" }

// Delete a value
await kv.delete(["users", "alice"]);

Keys

Keys are arrays of "key parts" that form a hierarchy:

<!-- deno-fmt-ignore -->
// Simple key
["settings"]

// Hierarchical keys
["users", "alice"]
["users", "bob"]
["posts", "2024", "01", "my-post"]

Key parts can be strings, numbers, booleans, Uint8Array, or bigints.

Basic Operations

Get

const result = await kv.get<User>(["users", "alice"]);
if (result.value) {
  console.log(result.value.name);
}

Set

await kv.set(["users", "alice"], { name: "Alice" });

// With expiration (in milliseconds)
await kv.set(["sessions", sessionId], data, { expireIn: 3600000 }); // 1 hour

Delete

await kv.delete(["users", "alice"]);

List

// List all users
const users = kv.list<User>({ prefix: ["users"] });
for await (const entry of users) {
  console.log(entry.key, entry.value);
}

// With limit
const firstTen = kv.list<User>({ prefix: ["users"] }, { limit: 10 });

Atomic Transactions

Perform multiple operations atomically (all succeed or all fail):

// Transfer credits between users
const alice = await kv.get<number>(["credits", "alice"]);
const bob = await kv.get<number>(["credits", "bob"]);

const result = await kv.atomic()
  .check(alice) // Ensure alice hasn't changed
  .check(bob) // Ensure bob hasn't changed
  .set(["credits", "alice"], alice.value! - 100)
  .set(["credits", "bob"], bob.value! + 100)
  .commit();

if (!result.ok) {
  console.log("Transaction failed - data was modified");
}

Example: Request Counter

const kv = await Deno.openKv();

Deno.serve(async () => {
  // Increment counter atomically
  const key = ["requests"];

  let result = { ok: false };
  while (!result.ok) {
    const current = await kv.get<number>(key);
    const newCount = (current.value ?? 0) + 1;

    result = await kv.atomic()
      .check(current)
      .set(key, newCount)
      .commit();
  }

  const count = (await kv.get<number>(key)).value;
  return new Response(`Requests: ${count}`);
});

Data Location

On Deno Deploy, KV data is replicated across at least three data centers in Northern Virginia (us-east-4). Cross-region replication is not currently available.

Local Development

When running locally with deno run, KV data is stored in memory by default. For persistent local storage:

// Persist to a local file
const kv = await Deno.openKv("./my-database.sqlite");

Important Notes

  • Deletion is permanent - Deleting a KV instance removes all data with no recovery
  • Back up important data before deleting instances
  • No cross-region replication yet - data lives in us-east-4

Documentation

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides safe and standard reference guidelines and deployment documentation for the Deno Deploy CLI. It covers configuration files, environment variables, command references, and databases without introducing dangerous command scripts, malicious prompt adjustments, obfuscated paths, or external download vulnerabilities.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    9/9 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 2311d69. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Steadyupdated 2 months ago
metadata
{
  "author": "denoland",
  "version": "1.5"
}
  • CLI
  • deno
  • deno-deploy
  • deployment
  • environment-variables
  • kv
  • custom-domains
  • production

README badge

README badge for denoland/skills/deno-deploy

Guides deployment of Deno applications to Deno Deploy using the `deno deploy` CLI (requires Deno >= 2.4.2). Covers app creation, production and preview deploys, environment variables across contexts, KV database provisioning, and the `--tunnel` flag for local development.

Generated from the current SKILL.md.

Does this skill cover the deprecated `deployctl` command?
No. This skill uses only the modern `deno deploy` command (requires Deno >= 2.4.2). The `deployctl` command is deprecated and not covered.
Can I use this skill to deploy to other platforms like Vercel or AWS Lambda?
No. This skill applies only to Deno Deploy. For other platforms, use their platform-specific guidance directly.
What should I do if my app connects to a database at startup?
Create the app with `--no-wait`, provision and assign the database with `deno deploy database` commands, then redeploy so the database exists before warmup.
Do I need to add configuration to deno.json before deploying?
Only if you have an existing app on Deno Deploy. For new apps, `deno deploy create` sets up the config automatically. For subsequent deploys, `deno deploy --prod` uses the stored org and app names.
How do I set different environment variables for production and preview deployments?
Deno Deploy supports separate contexts: Production (live traffic), Development (previews), and Build (during builds). You can set different values for the same variable in each context using the CLI.

Generated from the current SKILL.md. These answers refresh after source changes.