Deno Tutorial
Learn Deno step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is Deno? Learn what Deno is, why Ryan Dahl built it, how it differs from a browser and from Node.js, and what you get out of the box - TypeScript, permissions, web APIs and one tool.
- Installing Deno Install Deno with a shell script, a package manager, npm or Docker, check the version, upgrade, set up an editor and enable shell completions on Windows, macOS and Linux.
- Your First Deno Program Write and run your first Deno program with deno run, try code in the REPL and deno eval, scaffold a project with deno init, add tasks to deno.json and use watch mode.
- Deno vs Node.js Compare Deno and Node.js on modules, TypeScript, permissions, APIs, tooling and packages. Learn what is the same, what differs, and how to move code between the two.
Language and Runtime Basics
- TypeScript in Deno Use TypeScript in Deno with no setup. Learn how running differs from type checking, how deno check works, strict compiler options in deno.json, type-only imports and JSX.
- The Deno Namespace and Runtime APIs Tour the Deno global object - version and build info, cwd, pid, memory, standard streams, typed errors, signals, and how to feature-detect APIs so your code stays portable.
- Async Code and Top-Level Await Write asynchronous Deno code with promises and async/await, use top-level await in modules, run tasks in parallel, handle timeouts and cancellation, and meet the @std/async helpers.
- Reading and Writing Files Read, write, append, copy, remove and list files in Deno with Deno.readTextFile, writeTextFile, open, readDir and stat. Handle errors, use streams for large files and grant permissions.
- Command-Line Arguments and Environment Variables Read command-line arguments with Deno.args and parseArgs, use Deno.env and .env files for configuration, validate settings, set exit codes and build a small CLI tool in Deno.
Modules and Permissions
- ES Modules and URL Imports Understand how Deno resolves imports - ES modules, explicit file extensions, URL and remote imports, caching and lockfiles, dynamic import(), import.meta and circular dependencies.
- Import Maps and deno.json Configure a Deno project with deno.json - import maps for short names, tasks, compilerOptions, fmt and lint settings, exclude, lock files and workspaces for monorepos.
- JSR and npm Packages Use packages in Deno from JSR and npm with jsr: and npm: specifiers, version ranges, node_modules and package.json support, deno install, publishing to JSR and Node compatibility tips.
- Permissions Understand Deno's permission model - allow flags for read, write, net, env, run, ffi and sys, scoped values, deny flags, prompts, the Deno.permissions API, and how to grant the least access.
Standard Library and Web APIs
- The Deno Standard Library Explore the Deno standard library on JSR - how @std packages are organised and versioned, key modules like assert, collections, fmt, text, async, cli and dotenv, with usage patterns.
- fetch and the Web APIs Make HTTP requests in Deno with fetch, build Request and Response objects, work with Headers, JSON, FormData and URLSearchParams, handle errors and timeouts, and need only --allow-net.
- URL, Streams and Encoding Work with URL and URLPattern, ReadableStream and TransformStream pipelines, text encodings, base64 and hex, Blob and compression streams in Deno using web standard APIs.
- Path, FS and Data Formats Handle paths, walk directory trees and glob files with @std/path and @std/fs, and read or write JSON, CSV, YAML and TOML in Deno with the standard library and built-in JSON.
- Web Crypto, Randomness and Timers Use the Web Crypto API in Deno for random values, UUIDs, SHA hashes, HMAC signatures and AES-GCM encryption, plus timers, performance.now and Intl date formatting - all runnable examples.
HTTP Servers
- HTTP Servers with Deno.serve Build your first HTTP server in Deno with Deno.serve. Learn handlers, Request and Response, ports, permissions, graceful shutdown and how to test a handler without a network.
- Requests and Responses in Deno Read query strings, JSON bodies, forms and headers from a Deno Request, build correct Responses with status codes, cookies and CORS headers, and handle errors and bad input safely.
- Routing, Middleware and Static Files in Deno Route requests in Deno with URLPattern, compose middleware for logging and auth, serve static files with the standard library and see when a framework like Hono or Oak is worth adding.
- Streaming, Server-Sent Events and WebSockets in Deno Send data to clients as it is produced. Stream response bodies, push Server-Sent Events, upgrade connections to WebSockets with Deno.upgradeWebSocket and build a broadcast hub.
Testing and Tooling
- Testing in Deno with deno test Write tests with Deno.test, group them in steps, filter and parallelize runs, read coverage reports, test servers by calling handlers and measure speed with deno bench. No extra tools needed.
- Assertions, BDD and Mocking in Deno Tests Use @std/assert for clear failures, describe and it with hooks from @std/testing/bdd, spies and stubs for mocking, FakeTime for timers and snapshots, with runnable stand-ins of each idea.
- Formatting, Linting and Type Checking in Deno Keep code consistent with deno fmt, catch bugs with deno lint rules and ignore comments, type-check with deno check, read docs with deno doc and wire it all into CI. No config files needed.
- Configuration and Tasks with deno.json Configure a Deno project with deno.json. Define tasks and task dependencies, import maps, compiler options, lockfiles, env files and workspaces, and understand how each setting is resolved.
Deno KV and Data
- Deno KV Basics Store data with Deno KV, the built-in key-value database. Learn hierarchical keys, get, set, delete, versionstamps, listing by prefix and range, pagination, expiry and secondary indexes.
- Deno KV Atomic Operations, Queues and Watch Make safe multi-key updates with Deno KV atomic operations, handle races with versionstamp checks and retries, count with sum, run background jobs with queues and react to changes with watch.
- Data Formats, SQLite and Databases in Deno Read and write JSON, CSV, YAML and TOML with the Deno standard library, store relational data in SQLite with node:sqlite and prepared statements, and connect to Postgres, MySQL and MongoDB.
Deploy and Interop
- npm Packages and Node.js Compatibility in Deno Use the npm ecosystem from Deno with npm: specifiers, package.json and node_modules, the node: built-in modules, CommonJS interop, lifecycle scripts, and a plan for migrating a Node.js project.
- Publishing Packages to JSR Share a TypeScript library on JSR, the JavaScript Registry. Prepare deno.json, exports, JSDoc and types, follow semver, run deno publish with dry runs and automate releases from GitHub Actions.
- Workers, FFI and WebAssembly in Deno Run CPU-heavy work off the main thread with Web Workers, call native libraries with Deno.dlopen and FFI, and run fast portable code with WebAssembly. Includes permissions and safety notes.
- Deploy, Compile and Docker: Shipping Deno Apps Put a Deno app into production. Compare Deno Deploy, a compiled single binary, Docker and a Linux server, and learn env configuration, health checks, graceful shutdown, cron jobs and logging.
Projects and Practice
- Project: Build a URL Shortener with Deno and KV Build a complete URL shortener in Deno. Validate URLs, generate unique short codes with atomic KV writes, redirect visitors, count clicks safely, expose stats and test every route.
- Project: A To-Do REST API with Auth and Pagination Build a complete REST API in Deno with Deno KV. Add API-key middleware, validation, filtering, cursor pagination and optimistic concurrency with ETag and If-Match, then test it without a server.
- Project: A Real-Time Chat with WebSockets and KV Build a real-time chat server in Deno. Use WebSockets for rooms, Deno KV for message history, a rate limiter, input validation and BroadcastChannel to link several server instances, plus the browser client.
- Practice: Deno Exercises, Review and Cheat Sheet Test your Deno skills with eight exercises on servers, routing, rate limiting, CSV, tests, KV key design, permissions and Docker, with runnable solutions, review questions and a command cheat sheet.