Skip to content

Commit 9db7069

Browse files
authored
Turborepo + Hono example (#1168)
### Description Adding a Turborepo + Hono example ### Type of Change - [x] New Example - [ ] Example updates (Bug fixes, new features, etc.) - [ ] Other (changes to the codebase, but not to examples)
1 parent 6d57157 commit 9db7069

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6163
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# Dependencies
4+
node_modules
5+
.pnp
6+
.pnp.js
7+
8+
# Local env files
9+
.env
10+
.env.local
11+
.env.development.local
12+
.env.test.local
13+
.env.production.local
14+
15+
# Testing
16+
coverage
17+
18+
# Turbo
19+
.turbo
20+
21+
# Vercel
22+
.vercel
23+
24+
# Build Outputs
25+
.next/
26+
out/
27+
build
28+
dist
29+
30+
31+
# Debug
32+
npm-debug.log*
33+
yarn-debug.log*
34+
yarn-error.log*
35+
36+
# Misc
37+
.DS_Store
38+
*.pem

starter/turborepo-with-hono/.npmrc

Whitespace-only changes.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Turborepo starter
2+
3+
This Turborepo starter is maintained by the Turborepo core team.
4+
5+
## Using this example
6+
7+
Run the following command:
8+
9+
```sh
10+
npx create-turbo@latest
11+
```
12+
13+
## What's inside?
14+
15+
This Turborepo includes the following packages/apps:
16+
17+
### Apps and Packages
18+
19+
- `docs`: a [Next.js](https://nextjs.org/) app
20+
- `web`: another [Next.js](https://nextjs.org/) app
21+
- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications
22+
- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
23+
- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo
24+
25+
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
26+
27+
### Utilities
28+
29+
This Turborepo has some additional tools already setup for you:
30+
31+
- [TypeScript](https://www.typescriptlang.org/) for static type checking
32+
- [ESLint](https://eslint.org/) for code linting
33+
- [Prettier](https://prettier.io) for code formatting
34+
35+
### Build
36+
37+
To build all apps and packages, run the following command:
38+
39+
```
40+
cd my-turborepo
41+
42+
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
43+
turbo build
44+
45+
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
46+
npx turbo build
47+
yarn dlx turbo build
48+
pnpm exec turbo build
49+
```
50+
51+
You can build a specific package by using a [filter](https://turborepo.com/docs/crafting-your-repository/running-tasks#using-filters):
52+
53+
```
54+
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
55+
turbo build --filter=docs
56+
57+
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
58+
npx turbo build --filter=docs
59+
yarn exec turbo build --filter=docs
60+
pnpm exec turbo build --filter=docs
61+
```
62+
63+
### Develop
64+
65+
To develop all apps and packages, run the following command:
66+
67+
```
68+
cd my-turborepo
69+
70+
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
71+
turbo dev
72+
73+
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
74+
npx turbo dev
75+
yarn exec turbo dev
76+
pnpm exec turbo dev
77+
```
78+
79+
You can develop a specific package by using a [filter](https://turborepo.com/docs/crafting-your-repository/running-tasks#using-filters):
80+
81+
```
82+
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
83+
turbo dev --filter=web
84+
85+
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
86+
npx turbo dev --filter=web
87+
yarn exec turbo dev --filter=web
88+
pnpm exec turbo dev --filter=web
89+
```
90+
91+
### Remote Caching
92+
93+
> [!TIP]
94+
> Vercel Remote Cache is free for all plans. Get started today at [vercel.com](https://vercel.com/signup?/signup?utm_source=remote-cache-sdk&utm_campaign=free_remote_cache).
95+
96+
Turborepo can use a technique known as [Remote Caching](https://turborepo.com/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
97+
98+
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup?utm_source=turborepo-examples), then enter the following commands:
99+
100+
```
101+
cd my-turborepo
102+
103+
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
104+
turbo login
105+
106+
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
107+
npx turbo login
108+
yarn exec turbo login
109+
pnpm exec turbo login
110+
```
111+
112+
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
113+
114+
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
115+
116+
```
117+
# With [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation) installed (recommended)
118+
turbo link
119+
120+
# Without [global `turbo`](https://turborepo.com/docs/getting-started/installation#global-installation), use your package manager
121+
npx turbo link
122+
yarn exec turbo link
123+
pnpm exec turbo link
124+
```
125+
126+
## Useful Links
127+
128+
Learn more about the power of Turborepo:
129+
130+
- [Tasks](https://turborepo.com/docs/crafting-your-repository/running-tasks)
131+
- [Caching](https://turborepo.com/docs/crafting-your-repository/caching)
132+
- [Remote Caching](https://turborepo.com/docs/core-concepts/remote-caching)
133+
- [Filtering](https://turborepo.com/docs/crafting-your-repository/running-tasks#using-filters)
134+
- [Configuration Options](https://turborepo.com/docs/reference/configuration)
135+
- [CLI Usage](https://turborepo.com/docs/reference/command-line-reference)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# dev
2+
.yarn/
3+
!.yarn/releases
4+
.vscode/*
5+
!.vscode/launch.json
6+
!.vscode/*.code-snippets
7+
.idea/workspace.xml
8+
.idea/usage.statistics.xml
9+
.idea/shelf
10+
11+
# deps
12+
node_modules/
13+
14+
# env
15+
.env
16+
.env.production
17+
18+
# logs
19+
logs/
20+
*.log
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
pnpm-debug.log*
25+
lerna-debug.log*
26+
27+
# misc
28+
.DS_Store
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
```
2+
npm install
3+
npm run dev
4+
```
5+
6+
```
7+
open http://localhost:3000
8+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "api",
3+
"type": "module",
4+
"scripts": {
5+
"dev": "vc dev",
6+
"build": "vc build"
7+
},
8+
"dependencies": {
9+
"@hono/node-server": "^1.18.0",
10+
"hono": "^4.8.10"
11+
},
12+
"devDependencies": {
13+
"@types/node": "^20.11.17",
14+
"tsx": "^4.7.1",
15+
"typescript": "^5.8.3",
16+
"vercel": "latest"
17+
}
18+
}
19+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Hono } from "hono";
2+
3+
const app = new Hono();
4+
5+
app.get("/", (c) => {
6+
return c.text("Hello from the Hono API!");
7+
});
8+
9+
export default app;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "NodeNext",
5+
"strict": true,
6+
"verbatimModuleSyntax": true,
7+
"skipLibCheck": true,
8+
"types": [
9+
"node"
10+
],
11+
"jsx": "react-jsx",
12+
"jsxImportSource": "hono/jsx",
13+
"outDir": "./dist"
14+
},
15+
"exclude": ["node_modules"]
16+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
8+
9+
# testing
10+
/coverage
11+
12+
# next.js
13+
/.next/
14+
/out/
15+
16+
# production
17+
/build
18+
19+
# misc
20+
.DS_Store
21+
*.pem
22+
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
27+
28+
# env files (can opt-in for commiting if needed)
29+
.env*
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
# or
12+
pnpm dev
13+
# or
14+
bun dev
15+
```
16+
17+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
18+
19+
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
20+
21+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load Inter, a custom Google Font.
22+
23+
## Learn More
24+
25+
To learn more about Next.js, take a look at the following resources:
26+
27+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29+
30+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
31+
32+
## Deploy on Vercel
33+
34+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
35+
36+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

0 commit comments

Comments
 (0)