DEV Community

Cover image for The first step of Bun
Ken Obara
Ken Obara

Posted on

The first step of Bun

As you know, Bun is the fastest JavaScript runtime and the substitute for Node.js.

Today, I want to introduce the first step of Bun.

Install Bun globally

# Open your terminal
$ curl -fsSL https://bun.sh/install | bash
Enter fullscreen mode Exit fullscreen mode

Create a TypeScript file

# In your terminal
$ touch index.tsx
Enter fullscreen mode Exit fullscreen mode
// index.tsx
const server = Bun.serve({
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
});

console.log(`Listening on localhost:${server.port}`);
Enter fullscreen mode Exit fullscreen mode

Lounch a server with Bun

# In your terminal
$ bun run index.tsx
Enter fullscreen mode Exit fullscreen mode

http://localhost:3000/

Welcome to Bun!!!

Image description

Top comments (0)