Skip to content

Commit b2adf5c

Browse files
authored
Add nitro-bun template (#1279)
Add a new Nitro template using Bun as a runtime instead of Node.js. This requires `[email protected]` or higher (https://github.com/nitrojs/nitro/releases/tag/v2.12.9)
1 parent 4030c4e commit b2adf5c

File tree

9 files changed

+1212
-0
lines changed

9 files changed

+1212
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
dist
3+
.data
4+
.nitro
5+
.cache
6+
.output
7+
.env
8+
.vercel
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shamefully-hoist=true
2+
strict-peer-dependencies=false
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Nitro
2+
3+
This directory is a brief example of [Nitro](https://nitro.build/) and [Bun](https://bun.com) that can be deployed to Vercel with zero configuration. Go to the [nitro quick start](https://nitro.unjs.io/guide#quick-start) to learn more.
4+
5+
## Deploy Your Own
6+
7+
Deploy your own Nitro project with Vercel and Bun.
8+
9+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/framework-boilerplates/nitro-bun&template=nitro)
10+
11+
Live Example: https://example-nitro-bun.vercel.app/
12+
13+
## Developing
14+
15+
Once you've created a project and installed dependencies with `bun install`, start a development server:
16+
17+
```bash
18+
bun run dev
19+
```

framework-boilerplates/nitro-bun/bun.lock

Lines changed: 1069 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//https://nitro.unjs.io/config
2+
export default defineNitroConfig({
3+
srcDir: "server",
4+
compatibilityDate: "2025-10-28",
5+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"build": "nitro build",
5+
"dev": "nitro dev",
6+
"prepare": "nitro prepare",
7+
"preview": "node .output/server/index.mjs"
8+
},
9+
"dependencies": {
10+
"nitropack": "latest"
11+
}
12+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
export default defineEventHandler((event) => {
2+
return `
3+
<!DOCTYPE html>
4+
<html lang="en">
5+
<head>
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Nitro + Bun on Vercel</title>
9+
<style>
10+
* { margin: 0; padding: 0; box-sizing: border-box; }
11+
body {
12+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
13+
background: linear-gradient(135deg, #000 0%, #111 100%);
14+
color: #fff;
15+
min-height: 100vh;
16+
display: flex;
17+
align-items: center;
18+
justify-content: center;
19+
}
20+
.container {
21+
text-align: center;
22+
max-width: 600px;
23+
padding: 2rem;
24+
}
25+
.logo {
26+
width: 60px;
27+
height: 60px;
28+
border-radius: 12px;
29+
margin: 0 auto 2rem;
30+
display: flex;
31+
align-items: center;
32+
justify-content: center;
33+
font-weight: bold;
34+
font-size: 1.5rem;
35+
}
36+
h1 {
37+
font-size: 3rem;
38+
font-weight: 700;
39+
margin-bottom: 1rem;
40+
color: white;
41+
}
42+
p {
43+
font-size: 1.125rem;
44+
color: #888;
45+
margin-bottom: 2rem;
46+
line-height: 1.6;
47+
}
48+
.features {
49+
display: grid;
50+
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
51+
gap: 1rem;
52+
margin-top: 2rem;
53+
}
54+
.feature {
55+
background: rgba(255, 255, 255, 0.05);
56+
border: 1px solid rgba(255, 255, 255, 0.1);
57+
border-radius: 8px;
58+
padding: 1rem;
59+
backdrop-filter: blur(10px);
60+
}
61+
.feature h3 {
62+
font-size: 0.875rem;
63+
font-weight: 600;
64+
margin-bottom: 0.5rem;
65+
}
66+
.feature a {
67+
font-size: 1rem;
68+
color: white;
69+
margin: 0;
70+
}
71+
</style>
72+
</head>
73+
<body>
74+
<div class="container">
75+
<img src="https://nitro.build/icon.svg" alt="Nitro logo" class="logo" />
76+
<h1>Welcome to Nitro + Bun ${process.versions.bun}</h1>
77+
<p>A fast, lightweight server framework running on Vercel</p>
78+
<div class="features">
79+
<div class="feature">
80+
<a href="https://vercel.com/docs/frameworks/nitro" target="_blank" rel="noreferrer">▲ Vercel docs</a>
81+
</div>
82+
<div class="feature">
83+
<a href="https://nitro.build/deploy/providers/vercel" target="_blank" rel="noreferrer">⚡ Nitro docs</a>
84+
</div>
85+
</div>
86+
</div>
87+
</body>
88+
</html>
89+
`
90+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// https://nitro.unjs.io/guide/typescript
2+
{
3+
"extends": "./.nitro/types/tsconfig.json"
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"bunVersion": "1.x"
3+
}

0 commit comments

Comments
 (0)