Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 ยท 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.

Deno is a runtime for JavaScript and TypeScript that runs outside the browser. You give it a file, it runs the file, and your code can read files, open network connections and talk to the operating system, just like a Node.js program can. Deno is built on the same V8 engine that powers Chrome, and its core is written in Rust.

What makes Deno interesting is not that it runs JavaScript, but the decisions it made on top of the engine. TypeScript works with no setup. Programs cannot touch your disk or network unless you allow it. The browser's own APIs, such as fetch, are available everywhere. And a single executable includes a formatter, linter, test runner and bundler. This lesson explains those ideas; the next ones put them to work.

Deno is not installed on this site, so the Deno commands in this course are read-only code blocks. Wherever a lesson has a runnable example, it uses plain JavaScript or TypeScript that behaves the same in Deno, Node.js and the browser, and the page says so.

A short history

Ryan Dahl created Node.js in 2009. In 2018 he gave a talk listing regrets about it: no security model, a complicated module system built around node_modules, and a build system that leaned on non-standard tools. He started Deno (an anagram of "Node") to fix those issues with hindsight. Deno 1.0 arrived in 2020. Deno 2.0 (2024) made it much easier to adopt in existing projects by supporting package.json, node_modules and most npm packages.

Today the project is split into a few pieces you will meet in this course:

  • The Deno runtime and CLI, the deno command.
  • The standard library, a set of reviewed, versioned modules published on JSR (the JavaScript Registry) as @std/....
  • Deno Deploy, a hosting service for Deno programs (covered in the Deploy chapter).
  • Deno KV, a built-in key-value database (covered later too).

What you get out of the box

Why people pick Deno

TypeScript built in Run .ts files directly
Secure by default No disk or network without a flag
Web standard APIs fetch, URL, streams, Web Crypto
One tool fmt, lint, test, compile

Four ideas shape almost everything in Deno.

1 / 3

Let us look at the four headline ideas.

TypeScript without setup

With Node.js you traditionally install a compiler, write a tsconfig.json and add a build step. In Deno you write main.ts and run deno run main.ts. Deno strips the types and runs the JavaScript underneath. The next lessons cover what that means for type checking.

Secure by default

A script you download should not be able to read your SSH keys. Deno makes that the default. Every capability, such as reading a file, making a request or reading an environment variable, needs a permission. You grant permissions with flags on the command line, or answer a prompt in the terminal. Permissions gets a full lesson.

Web platform APIs

If you know fetch, URL, Request, Response, TextEncoder, AbortController or crypto.randomUUID() from the browser, you already know them in Deno. They are globals with the same behaviour. Deno also adds its own Deno namespace for things a browser cannot do, like Deno.readTextFile.

One tool

deno fmt formats code, deno lint finds problems, deno test runs tests, deno bench measures speed, deno doc builds documentation, and deno compile turns your program into a standalone executable. They need no plugins or configuration to start.

Seeing the web APIs work

The code below uses only web standard APIs, so it runs the same in Deno, in Node.js 18 and later, and in a modern browser. Try it.

Node.js Web APIs are the common ground

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

How it compares to a browser

A browser runs untrusted code from the web, so it has no file access and a strict sandbox. Deno gives programs more power than a page has, but keeps the same attitude of "ask first". Think of it as a browser-like runtime for the command line and servers: same standard APIs, plus controlled access to the system.

flowchart LR
  A["Your code (.ts / .js)"] --> B["Deno CLI"]
  B --> C["TypeScript stripped by swc"]
  C --> D["V8 engine"]
  D --> E["Web APIs: fetch, URL, streams"]
  D --> F["Deno namespace: files, env, net"]
  F --> G{"Permission granted?"}
  G -->|yes| H["Operating system"]
  G -->|no| I["Prompt or error"]

Every call that touches the system goes through the permission check.

What Deno is good for

  • Scripts and automation. A single .ts file with typed code, easy to share by URL.
  • Web servers and APIs. Deno.serve is built in and fast (HTTP Servers chapter).
  • Command-line tools. deno compile produces one executable with no runtime to install.
  • Edge and serverless. The same code runs on Deno Deploy.
  • Learning. No toolchain to configure, so you spend time on the language.

It is a weaker fit when a project depends on a native Node.js addon that Deno does not support, or when your team's whole pipeline is built around Node.js tooling you do not want to move. Even then, Deno 2 runs a large part of the npm ecosystem, so check before ruling it out.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which engine does Deno use to run JavaScript?

    Deno embeds V8, the same engine used by Chrome and Node.js. The runtime around it is written in Rust.
  2. 2. What happens when a Deno program tries to read a file without the read permission?

    Deno is secure by default. Without permission the operation fails with an error, or Deno prompts you in an interactive terminal.
  3. 3. Which of these needs no installation or flag in Deno?

    TypeScript is built in. Network, disk and environment access all need permissions.
  4. 4. Which release made Deno much easier to use with existing npm projects?

    Deno 2.0 added broad support for package.json, node_modules and npm packages.

Summary

  • Deno is a secure JavaScript and TypeScript runtime built on V8 and Rust, created by the author of Node.js.
  • TypeScript runs with no configuration, and ES modules are the only module system.
  • Permissions guard files, network, environment and more.
  • Web standard APIs are globals; the Deno namespace covers system features.
  • One executable bundles formatter, linter, test runner, compiler and more.
  • Deno 2 added npm and package.json compatibility.

Next: Installing Deno