Bun foundations

Understand what Bun includes

Meet Bun as a JavaScript runtime, package manager, test runner, and bundler in one executable.

6 minute lesson

~~~

Bun is a toolkit for JavaScript and TypeScript. It gives you several tools through one bun command.

You get:

  • a runtime for JavaScript and TypeScript
  • a package manager for npm packages
  • a test runner
  • a bundler

The runtime fills the same role as Node.js. You give it a program, and Bun runs that program outside the browser.

Bun uses JavaScriptCore, the JavaScript engine used by Safari. Node.js uses V8 instead. You usually notice the difference through startup speed, compatibility, and the APIs each runtime provides.

Bun still uses the JavaScript ecosystem

Bun does not ask you to leave npm packages behind. It reads package.json, creates node_modules, and installs packages from the npm registry.

It also implements many Node.js APIs. This means a Node.js project can often run with Bun after a small change:

bun run start

But compatibility is not a promise that every project works unchanged. A package may depend on a Node.js API Bun does not fully support. Native add-ons and runtime-specific behavior also need careful testing.

My advice is simple: treat Bun as its own runtime. Reuse Node.js packages where they work, but test the application with Bun before shipping it.

What we will build

During this course, we’ll build a small notes API. It will use TypeScript, Bun.serve(), and SQLite.

We’ll also test it, bundle it, and compile it into an executable. This gives us a useful path through every important part of Bun.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →