├── .github └── workflows │ └── sync-branch.yml ├── .gitignore ├── .prettierrc ├── .vscode └── settings.json ├── .yarn └── releases │ └── yarn-3.4.1.cjs ├── .yarnrc.yml ├── README.md ├── package.json └── templates ├── aws-lambda ├── .gitignore ├── README.md ├── package.json ├── src │ └── index.ts └── tsconfig.json ├── bun ├── .gitignore ├── README.md ├── package.json ├── src │ └── index.ts └── tsconfig.json ├── cloudflare-pages ├── .gitignore ├── README.md ├── package.json ├── public │ └── static │ │ └── style.css ├── src │ ├── index.tsx │ └── renderer.tsx ├── tsconfig.json ├── vite.config.ts └── wrangler.jsonc ├── cloudflare-workers+vite ├── .gitignore ├── README.md ├── package.json ├── public │ ├── .assetsignore │ └── favicon.ico ├── src │ ├── index.tsx │ ├── renderer.tsx │ └── style.css ├── tsconfig.json ├── vite.config.ts └── wrangler.jsonc ├── cloudflare-workers ├── .gitignore ├── README.md ├── package.json ├── src │ └── index.ts ├── tsconfig.json └── wrangler.jsonc ├── deno ├── .vscode │ ├── extensions.json │ └── settings.json ├── README.md ├── deno.json └── main.ts ├── fastly ├── README.md ├── build.js ├── fastly.toml ├── package.json └── src │ └── index.ts ├── lambda-edge ├── .gitignore ├── README.md ├── package.json ├── src │ └── index.ts └── tsconfig.json ├── netlify ├── .gitignore ├── .vscode │ ├── extensions.json │ └── settings.json ├── netlify.toml └── netlify │ └── edge-functions │ └── index.ts ├── nextjs ├── .gitignore ├── README.md ├── app │ ├── api │ │ └── [...route] │ │ │ └── route.ts │ ├── layout.tsx │ └── page.tsx ├── next-env.d.ts ├── next.config.js ├── package.json └── tsconfig.json ├── nodejs ├── .gitignore ├── README.md ├── package.json ├── src │ └── index.ts └── tsconfig.json ├── vercel ├── .gitignore ├── README.md ├── api │ └── index.ts ├── package.json ├── public │ └── favicon.ico ├── tsconfig.json └── vercel.json └── x-basic ├── .gitignore ├── app ├── client.ts ├── global.d.ts ├── islands │ └── counter.tsx ├── routes │ ├── _404.tsx │ ├── _error.tsx │ ├── _renderer.tsx │ └── index.tsx ├── server.ts └── style.css ├── package.json ├── public ├── .assetsignore └── favicon.ico ├── tsconfig.json ├── vite.config.ts └── wrangler.jsonc /.github/workflows/sync-branch.yml: -------------------------------------------------------------------------------- 1 | name: Sync versioned branch 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | sync_branch: 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | with: 19 | token: ${{ secrets.GITHUB_TOKEN }} 20 | 21 | - name: Setup Node.js 22 | uses: actions/setup-node@v4 23 | with: 24 | node-version: 22 25 | 26 | - name: Get create-hono version 27 | id: get_version 28 | run: | 29 | VERSION=$(npm show create-hono version) 30 | MAJOR_MINOR=$(echo "$VERSION" | cut -d '.' -f 1,2) 31 | echo "Detected version: $VERSION" 32 | echo "Branch name: v$MAJOR_MINOR" 33 | echo "branch_name=v$MAJOR_MINOR" >> "$GITHUB_ENV" 34 | 35 | - name: Setup Git 36 | run: | 37 | git config user.name "github-actions[bot]" 38 | git config user.email "41898282+github-actions[bot]@users.noreply.github.com" 39 | 40 | - name: Sync branch 41 | run: | 42 | git fetch origin 43 | git switch ${{ env.branch_name }} || git switch -c ${{ env.branch_name }} 44 | git reset --hard origin/main 45 | git push origin ${{ env.branch_name }} --force 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | yarn-error.log 4 | package-lock.json 5 | bin 6 | pkg 7 | .next 8 | deno.lock 9 | 10 | # yarn 11 | .yarn/* 12 | !.yarn/patches 13 | !.yarn/plugins 14 | !.yarn/releases 15 | !.yarn/sdks 16 | !.yarn/versions 17 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "trailingComma": "none", 4 | "tabWidth": 2, 5 | "semi": false, 6 | "singleQuote": true, 7 | "endOfLine": "lf" 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.codeActionsOnSave": { 3 | "source.organizeImports": "explicit" 4 | } 5 | } -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | yarnPath: .yarn/releases/yarn-3.4.1.cjs 2 | nodeLinker: node-modules 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hono Starter Templates 2 | 3 | You can start to build a Hono application with `create hono` command: 4 | 5 | ```bash 6 | # npm 7 | npm create hono@latest 8 | 9 | # yarn 10 | yarn create hono 11 | 12 | # pnpm 13 | pnpm create hono@latest 14 | 15 | # bun 16 | bun create hono@latest 17 | 18 | # deno 19 | deno run -A npm:create-hono@latest 20 | ``` 21 | 22 | ## Author 23 | 24 | Yusuke Wada 25 | 26 | and Hono contributors 27 | 28 | ## License 29 | 30 | MIT 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "starters", 3 | "version": "0.0.0", 4 | "private": true, 5 | "workspaces": [ 6 | "templates/*" 7 | ], 8 | "scripts": { 9 | "format": "prettier 'templates/**/*.{ts,tsx}' --write" 10 | }, 11 | "license": "MIT", 12 | "packageManager": "yarn@3.4.1", 13 | "devDependencies": { 14 | "prettier": "^3.3.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /templates/aws-lambda/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | dist/ 3 | lambda.zip 4 | 5 | # dev 6 | .yarn/ 7 | !.yarn/releases 8 | .vscode/* 9 | !.vscode/launch.json 10 | !.vscode/*.code-snippets 11 | .idea/workspace.xml 12 | .idea/usage.statistics.xml 13 | .idea/shelf 14 | 15 | # deps 16 | node_modules/ 17 | 18 | # env 19 | .env 20 | .env.production 21 | 22 | # logs 23 | logs/ 24 | *.log 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | pnpm-debug.log* 29 | lerna-debug.log* 30 | 31 | # misc 32 | .DS_Store 33 | -------------------------------------------------------------------------------- /templates/aws-lambda/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | npm install 3 | npm run deploy 4 | ``` 5 | -------------------------------------------------------------------------------- /templates/aws-lambda/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "build": "esbuild --bundle --outfile=./dist/index.js --platform=node --target=node20 ./src/index.ts", 5 | "zip": "zip -j lambda.zip dist/index.js", 6 | "update": "aws lambda update-function-code --zip-file fileb://lambda.zip --function-name hello", 7 | "deploy": "run-s build zip update" 8 | }, 9 | "devDependencies": { 10 | "esbuild": "^0.21.4", 11 | "npm-run-all2": "^6.2.0" 12 | }, 13 | "dependencies": { 14 | "hono": "^4.7.11" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /templates/aws-lambda/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | import { handle } from 'hono/aws-lambda' 3 | 4 | const app = new Hono() 5 | 6 | app.get('/', (c) => { 7 | return c.text('Hello Hono!') 8 | }) 9 | 10 | export const handler = handle(app) 11 | -------------------------------------------------------------------------------- /templates/aws-lambda/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "strict": true, 7 | "skipLibCheck": true, 8 | "types": [ 9 | "node" 10 | ], 11 | "jsx": "react-jsx", 12 | "jsxImportSource": "hono/jsx", 13 | } 14 | } -------------------------------------------------------------------------------- /templates/bun/.gitignore: -------------------------------------------------------------------------------- 1 | # deps 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /templates/bun/README.md: -------------------------------------------------------------------------------- 1 | To install dependencies: 2 | ```sh 3 | bun install 4 | ``` 5 | 6 | To run: 7 | ```sh 8 | bun run dev 9 | ``` 10 | 11 | open http://localhost:3000 12 | -------------------------------------------------------------------------------- /templates/bun/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "bun run --hot src/index.ts" 4 | }, 5 | "dependencies": { 6 | "hono": "^4.7.11" 7 | }, 8 | "devDependencies": { 9 | "@types/bun": "latest" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /templates/bun/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | 3 | const app = new Hono() 4 | 5 | app.get('/', (c) => { 6 | return c.text('Hello Hono!') 7 | }) 8 | 9 | export default app 10 | -------------------------------------------------------------------------------- /templates/bun/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "jsx": "react-jsx", 5 | "jsxImportSource": "hono/jsx" 6 | } 7 | } -------------------------------------------------------------------------------- /templates/cloudflare-pages/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | dist/ 3 | 4 | # dev 5 | .yarn/ 6 | !.yarn/releases 7 | .vscode/* 8 | !.vscode/launch.json 9 | !.vscode/*.code-snippets 10 | .idea/workspace.xml 11 | .idea/usage.statistics.xml 12 | .idea/shelf 13 | 14 | # deps 15 | node_modules/ 16 | .wrangler 17 | 18 | # env 19 | .env 20 | .env.production 21 | .dev.vars 22 | 23 | # logs 24 | logs/ 25 | *.log 26 | npm-debug.log* 27 | yarn-debug.log* 28 | yarn-error.log* 29 | pnpm-debug.log* 30 | lerna-debug.log* 31 | 32 | # misc 33 | .DS_Store 34 | -------------------------------------------------------------------------------- /templates/cloudflare-pages/README.md: -------------------------------------------------------------------------------- 1 | ```txt 2 | npm install 3 | npm run dev 4 | ``` 5 | 6 | ```txt 7 | npm run deploy 8 | ``` 9 | 10 | [For generating/synchronizing types based on your Worker configuration run](https://developers.cloudflare.com/workers/wrangler/commands/#types): 11 | 12 | ```txt 13 | npm run cf-typegen 14 | ``` 15 | 16 | Pass the `CloudflareBindings` as generics when instantiation `Hono`: 17 | 18 | ```ts 19 | // src/index.ts 20 | const app = new Hono<{ Bindings: CloudflareBindings }>() 21 | ``` 22 | -------------------------------------------------------------------------------- /templates/cloudflare-pages/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "dev": "vite", 5 | "build": "vite build", 6 | "preview": "wrangler pages dev", 7 | "deploy": "$npm_execpath run build && wrangler pages deploy", 8 | "cf-typegen": "wrangler types --env-interface CloudflareBindings" 9 | }, 10 | "dependencies": { 11 | "hono": "^4.7.11" 12 | }, 13 | "devDependencies": { 14 | "@hono/vite-build": "^1.2.0", 15 | "@hono/vite-dev-server": "^0.18.2", 16 | "vite": "^6.3.5", 17 | "wrangler": "^4.4.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /templates/cloudflare-pages/public/static/style.css: -------------------------------------------------------------------------------- 1 | h1 { font-family: Arial, Helvetica, sans-serif; } -------------------------------------------------------------------------------- /templates/cloudflare-pages/src/index.tsx: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | import { renderer } from './renderer' 3 | 4 | const app = new Hono() 5 | 6 | app.use(renderer) 7 | 8 | app.get('/', (c) => { 9 | return c.render(

Hello!

) 10 | }) 11 | 12 | export default app 13 | -------------------------------------------------------------------------------- /templates/cloudflare-pages/src/renderer.tsx: -------------------------------------------------------------------------------- 1 | import { jsxRenderer } from 'hono/jsx-renderer' 2 | 3 | export const renderer = jsxRenderer(({ children }) => { 4 | return ( 5 | 6 | 7 | 8 | 9 | {children} 10 | 11 | ) 12 | }) 13 | -------------------------------------------------------------------------------- /templates/cloudflare-pages/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "strict": true, 7 | "skipLibCheck": true, 8 | "lib": [ 9 | "ESNext" 10 | ], 11 | "types": ["vite/client"], 12 | "jsx": "react-jsx", 13 | "jsxImportSource": "hono/jsx" 14 | }, 15 | } -------------------------------------------------------------------------------- /templates/cloudflare-pages/vite.config.ts: -------------------------------------------------------------------------------- 1 | import build from '@hono/vite-build/cloudflare-pages' 2 | import devServer from '@hono/vite-dev-server' 3 | import adapter from '@hono/vite-dev-server/cloudflare' 4 | import { defineConfig } from 'vite' 5 | 6 | export default defineConfig({ 7 | plugins: [ 8 | build(), 9 | devServer({ 10 | adapter, 11 | entry: 'src/index.tsx' 12 | }) 13 | ] 14 | }) 15 | -------------------------------------------------------------------------------- /templates/cloudflare-pages/wrangler.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "node_modules/wrangler/config-schema.json", 3 | "name": "%%PROJECT_NAME%%", 4 | "compatibility_date": "2024-04-01", 5 | "pages_build_output_dir": "./dist", 6 | "compatibility_flags": [ 7 | "nodejs_compat" 8 | ] 9 | // "vars": { 10 | // "MY_VAR": "my-variable" 11 | // }, 12 | // "kv_namespaces": [ 13 | // { 14 | // "binding": "MY_KV_NAMESPACE", 15 | // "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 16 | // } 17 | // ], 18 | // "r2_buckets": [ 19 | // { 20 | // "binding": "MY_BUCKET", 21 | // "bucket_name": "my-bucket" 22 | // } 23 | // ], 24 | // "d1_databases": [ 25 | // { 26 | // "binding": "MY_DB", 27 | // "database_name": "my-database", 28 | // "database_id": "" 29 | // } 30 | // ], 31 | // "ai": { 32 | // "binding": "AI" 33 | // } 34 | } -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | dist/ 3 | dist-server/ 4 | 5 | # dev 6 | .yarn/ 7 | !.yarn/releases 8 | .vscode/* 9 | !.vscode/launch.json 10 | !.vscode/*.code-snippets 11 | .idea/workspace.xml 12 | .idea/usage.statistics.xml 13 | .idea/shelf 14 | 15 | # deps 16 | node_modules/ 17 | .wrangler 18 | 19 | # env 20 | .env 21 | .env.production 22 | .dev.vars 23 | 24 | # logs 25 | logs/ 26 | *.log 27 | npm-debug.log* 28 | yarn-debug.log* 29 | yarn-error.log* 30 | pnpm-debug.log* 31 | lerna-debug.log* 32 | 33 | # misc 34 | .DS_Store 35 | -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/README.md: -------------------------------------------------------------------------------- 1 | ```txt 2 | npm install 3 | npm run dev 4 | ``` 5 | 6 | ```txt 7 | npm run deploy 8 | ``` 9 | 10 | [For generating/synchronizing types based on your Worker configuration run](https://developers.cloudflare.com/workers/wrangler/commands/#types): 11 | 12 | ```txt 13 | npm run cf-typegen 14 | ``` 15 | 16 | Pass the `CloudflareBindings` as generics when instantiation `Hono`: 17 | 18 | ```ts 19 | // src/index.ts 20 | const app = new Hono<{ Bindings: CloudflareBindings }>() 21 | ``` 22 | -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "dev": "vite", 5 | "build": "vite build", 6 | "preview": "$npm_execpath run build && vite preview", 7 | "deploy": "$npm_execpath run build && wrangler deploy", 8 | "cf-typegen": "wrangler types --env-interface CloudflareBindings" 9 | }, 10 | "dependencies": { 11 | "hono": "^4.7.11" 12 | }, 13 | "devDependencies": { 14 | "@cloudflare/vite-plugin": "^1.2.3", 15 | "vite": "^6.3.5", 16 | "vite-ssr-components": "^0.2.0", 17 | "wrangler": "^4.17.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/public/.assetsignore: -------------------------------------------------------------------------------- 1 | .vite -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/honojs/starter/243466b812b78e197900ccc2a3c4efa0bc924a86/templates/cloudflare-workers+vite/public/favicon.ico -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/src/index.tsx: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | import { renderer } from './renderer' 3 | 4 | const app = new Hono() 5 | 6 | app.use(renderer) 7 | 8 | app.get('/', (c) => { 9 | return c.render(

Hello!

) 10 | }) 11 | 12 | export default app 13 | -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/src/renderer.tsx: -------------------------------------------------------------------------------- 1 | import { jsxRenderer } from 'hono/jsx-renderer' 2 | import { Link, ViteClient } from 'vite-ssr-components/hono' 3 | 4 | export const renderer = jsxRenderer(({ children }) => { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | {children} 12 | 13 | ) 14 | }) 15 | -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/src/style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | font-family: Arial, Helvetica, sans-serif; 3 | } 4 | -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "strict": true, 7 | "skipLibCheck": true, 8 | "lib": [ 9 | "ESNext" 10 | ], 11 | "types": ["vite/client"], 12 | "jsx": "react-jsx", 13 | "jsxImportSource": "hono/jsx" 14 | }, 15 | } -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { cloudflare } from '@cloudflare/vite-plugin' 2 | import { defineConfig } from 'vite' 3 | import ssrPlugin from 'vite-ssr-components/plugin' 4 | 5 | export default defineConfig({ 6 | plugins: [cloudflare(), ssrPlugin()] 7 | }) 8 | -------------------------------------------------------------------------------- /templates/cloudflare-workers+vite/wrangler.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "node_modules/wrangler/config-schema.json", 3 | "name": "%%PROJECT_NAME%%", 4 | "compatibility_date": "2024-04-01", 5 | "main": "./src/index.tsx" 6 | } -------------------------------------------------------------------------------- /templates/cloudflare-workers/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | dist/ 3 | 4 | # dev 5 | .yarn/ 6 | !.yarn/releases 7 | .vscode/* 8 | !.vscode/launch.json 9 | !.vscode/*.code-snippets 10 | .idea/workspace.xml 11 | .idea/usage.statistics.xml 12 | .idea/shelf 13 | 14 | # deps 15 | node_modules/ 16 | .wrangler 17 | 18 | # env 19 | .env 20 | .env.production 21 | .dev.vars 22 | 23 | # logs 24 | logs/ 25 | *.log 26 | npm-debug.log* 27 | yarn-debug.log* 28 | yarn-error.log* 29 | pnpm-debug.log* 30 | lerna-debug.log* 31 | 32 | # misc 33 | .DS_Store 34 | -------------------------------------------------------------------------------- /templates/cloudflare-workers/README.md: -------------------------------------------------------------------------------- 1 | ```txt 2 | npm install 3 | npm run dev 4 | ``` 5 | 6 | ```txt 7 | npm run deploy 8 | ``` 9 | 10 | [For generating/synchronizing types based on your Worker configuration run](https://developers.cloudflare.com/workers/wrangler/commands/#types): 11 | 12 | ```txt 13 | npm run cf-typegen 14 | ``` 15 | 16 | Pass the `CloudflareBindings` as generics when instantiation `Hono`: 17 | 18 | ```ts 19 | // src/index.ts 20 | const app = new Hono<{ Bindings: CloudflareBindings }>() 21 | ``` 22 | -------------------------------------------------------------------------------- /templates/cloudflare-workers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "wrangler dev", 4 | "deploy": "wrangler deploy --minify", 5 | "cf-typegen": "wrangler types --env-interface CloudflareBindings" 6 | }, 7 | "dependencies": { 8 | "hono": "^4.7.11" 9 | }, 10 | "devDependencies": { 11 | "wrangler": "^4.4.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /templates/cloudflare-workers/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | 3 | const app = new Hono() 4 | 5 | app.get('/', (c) => { 6 | return c.text('Hello Hono!') 7 | }) 8 | 9 | export default app 10 | -------------------------------------------------------------------------------- /templates/cloudflare-workers/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "strict": true, 7 | "skipLibCheck": true, 8 | "lib": [ 9 | "ESNext" 10 | ], 11 | "jsx": "react-jsx", 12 | "jsxImportSource": "hono/jsx" 13 | }, 14 | } -------------------------------------------------------------------------------- /templates/cloudflare-workers/wrangler.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "node_modules/wrangler/config-schema.json", 3 | "name": "%%PROJECT_NAME%%", 4 | "main": "src/index.ts", 5 | "compatibility_date": "2024-04-01" 6 | // "compatibility_flags": [ 7 | // "nodejs_compat" 8 | // ], 9 | // "vars": { 10 | // "MY_VAR": "my-variable" 11 | // }, 12 | // "kv_namespaces": [ 13 | // { 14 | // "binding": "MY_KV_NAMESPACE", 15 | // "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 16 | // } 17 | // ], 18 | // "r2_buckets": [ 19 | // { 20 | // "binding": "MY_BUCKET", 21 | // "bucket_name": "my-bucket" 22 | // } 23 | // ], 24 | // "d1_databases": [ 25 | // { 26 | // "binding": "MY_DB", 27 | // "database_name": "my-database", 28 | // "database_id": "" 29 | // } 30 | // ], 31 | // "ai": { 32 | // "binding": "AI" 33 | // }, 34 | // "observability": { 35 | // "enabled": true, 36 | // "head_sampling_rate": 1 37 | // } 38 | } 39 | -------------------------------------------------------------------------------- /templates/deno/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "denoland.vscode-deno" 4 | ] 5 | } -------------------------------------------------------------------------------- /templates/deno/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enablePaths": [ 3 | "./" 4 | ], 5 | "editor.inlayHints.enabled": "off" 6 | } -------------------------------------------------------------------------------- /templates/deno/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | deno task start 3 | ``` 4 | -------------------------------------------------------------------------------- /templates/deno/deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "imports": { 3 | "hono": "jsr:@hono/hono@^4.7.11" 4 | }, 5 | "tasks": { 6 | "start": "deno run --allow-net main.ts" 7 | }, 8 | "compilerOptions": { 9 | "jsx": "precompile", 10 | "jsxImportSource": "hono/jsx" 11 | } 12 | } -------------------------------------------------------------------------------- /templates/deno/main.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | 3 | const app = new Hono() 4 | 5 | app.get('/', (c) => { 6 | return c.text('Hello Hono!') 7 | }) 8 | 9 | Deno.serve(app.fetch) 10 | -------------------------------------------------------------------------------- /templates/fastly/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | npm install 3 | npm run start 4 | ``` 5 | 6 | ``` 7 | open http://localhost:7676 8 | ``` 9 | 10 | ``` 11 | npm run deploy 12 | ``` 13 | -------------------------------------------------------------------------------- /templates/fastly/build.js: -------------------------------------------------------------------------------- 1 | import { build } from 'esbuild' 2 | 3 | await build({ 4 | entryPoints: ['src/index.ts'], 5 | bundle: true, 6 | minify: true, 7 | outfile: './dist/index.js', 8 | platform: 'neutral', 9 | external: ['fastly:*'] 10 | }) 11 | -------------------------------------------------------------------------------- /templates/fastly/fastly.toml: -------------------------------------------------------------------------------- 1 | # This file describes a Fastly Compute@Edge package. To learn more visit: 2 | # https://developer.fastly.com/reference/fastly-toml/ 3 | 4 | name = "Hono" 5 | authors = [""] 6 | description = "Starter for Hono" 7 | language = "javascript" 8 | manifest_version = 3 9 | service_id = "" 10 | 11 | [scripts] 12 | build = "npm run build" 13 | post_init = "npm install" 14 | -------------------------------------------------------------------------------- /templates/fastly/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "prebuild": "node build.js", 5 | "build": "js-compute-runtime ./dist/index.js ./bin/main.wasm", 6 | "start": "fastly compute serve", 7 | "deploy": "fastly compute publish" 8 | }, 9 | "dependencies": { 10 | "@fastly/js-compute": "^3.33.2", 11 | "hono": "^4.7.11" 12 | }, 13 | "devDependencies": { 14 | "@fastly/cli": "^11.0.0", 15 | "esbuild": "^0.25.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /templates/fastly/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono/quick' 2 | 3 | const app = new Hono() 4 | 5 | app.get('/', (c) => { 6 | return c.text('Hello Hono!') 7 | }) 8 | 9 | app.fire() 10 | -------------------------------------------------------------------------------- /templates/lambda-edge/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | dist/ 3 | lambda.zip 4 | 5 | # dev 6 | .yarn/ 7 | !.yarn/releases 8 | .vscode/* 9 | !.vscode/launch.json 10 | !.vscode/*.code-snippets 11 | .idea/workspace.xml 12 | .idea/usage.statistics.xml 13 | .idea/shelf 14 | 15 | # deps 16 | node_modules/ 17 | 18 | # env 19 | .env 20 | .env.production 21 | 22 | # logs 23 | logs/ 24 | *.log 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | pnpm-debug.log* 29 | lerna-debug.log* 30 | 31 | # misc 32 | .DS_Store 33 | -------------------------------------------------------------------------------- /templates/lambda-edge/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | npm install 3 | npm run deploy 4 | ``` 5 | -------------------------------------------------------------------------------- /templates/lambda-edge/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "build": "esbuild --bundle --outfile=./dist/index.js --platform=node --target=node20 ./src/index.ts", 5 | "zip": "zip -j lambda.zip dist/index.js", 6 | "update": "aws lambda update-function-code --zip-file fileb://lambda.zip --function-name hello --region us-east-1", 7 | "publish": "aws lambda publish-version --function-name hello --region us-east-1", 8 | "deploy": "run-s build zip update publish" 9 | }, 10 | "devDependencies": { 11 | "esbuild": "^0.21.4", 12 | "npm-run-all2": "^6.2.0" 13 | }, 14 | "dependencies": { 15 | "hono": "^4.7.11" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /templates/lambda-edge/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | import { handle } from 'hono/lambda-edge' 3 | 4 | const app = new Hono() 5 | 6 | app.get('/', (c) => { 7 | return c.text('Hello Hono!') 8 | }) 9 | 10 | export const handler = handle(app) 11 | -------------------------------------------------------------------------------- /templates/lambda-edge/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "strict": true, 7 | "skipLibCheck": true, 8 | "types": [ 9 | "node" 10 | ], 11 | "jsx": "react-jsx", 12 | "jsxImportSource": "hono/jsx", 13 | } 14 | } -------------------------------------------------------------------------------- /templates/netlify/.gitignore: -------------------------------------------------------------------------------- 1 | # dev 2 | .netlify/ 3 | .yarn/ 4 | !.yarn/releases 5 | .vscode/* 6 | !.vscode/launch.json 7 | !.vscode/*.code-snippets 8 | .idea/workspace.xml 9 | .idea/usage.statistics.xml 10 | .idea/shelf 11 | 12 | # deps 13 | node_modules/ 14 | 15 | # env 16 | .env 17 | .env.production 18 | 19 | # logs 20 | logs/ 21 | *.log 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | pnpm-debug.log* 26 | lerna-debug.log* 27 | 28 | # misc 29 | .DS_Store 30 | -------------------------------------------------------------------------------- /templates/netlify/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "denoland.vscode-deno" 4 | ] 5 | } -------------------------------------------------------------------------------- /templates/netlify/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enablePaths": [ 3 | "./" 4 | ], 5 | "editor.inlayHints.enabled": "off" 6 | } -------------------------------------------------------------------------------- /templates/netlify/netlify.toml: -------------------------------------------------------------------------------- 1 | [[edge_functions]] 2 | function = "index" 3 | path = "/*" -------------------------------------------------------------------------------- /templates/netlify/netlify/edge-functions/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'jsr:@hono/hono' 2 | import { handle } from 'jsr:@hono/hono/netlify' 3 | 4 | const app = new Hono() 5 | 6 | app.get('/', (c) => { 7 | return c.text('Hello Hono!') 8 | }) 9 | 10 | export default handle(app) 11 | -------------------------------------------------------------------------------- /templates/nextjs/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | out/ 3 | 4 | # dev 5 | .next/ 6 | .yarn/ 7 | !.yarn/releases 8 | .vscode/* 9 | !.vscode/launch.json 10 | !.vscode/*.code-snippets 11 | .idea/workspace.xml 12 | .idea/usage.statistics.xml 13 | .idea/shelf 14 | 15 | # deps 16 | node_modules/ 17 | 18 | # env 19 | .env 20 | .env.production 21 | 22 | # logs 23 | logs/ 24 | *.log 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | pnpm-debug.log* 29 | lerna-debug.log* 30 | 31 | # misc 32 | .DS_Store 33 | -------------------------------------------------------------------------------- /templates/nextjs/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | npm install 3 | npm run dev 4 | ``` 5 | -------------------------------------------------------------------------------- /templates/nextjs/app/api/[...route]/route.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | import { handle } from 'hono/vercel' 3 | 4 | export const runtime = 'edge' 5 | 6 | const app = new Hono().basePath('/api') 7 | 8 | app.get('/hello', (c) => { 9 | return c.json({ 10 | message: 'Hello from Hono!' 11 | }) 12 | }) 13 | 14 | export const GET = handle(app) 15 | -------------------------------------------------------------------------------- /templates/nextjs/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from 'next' 2 | 3 | export const metadata: Metadata = { 4 | title: 'Hono | nextjs', 5 | description: 'Generated by hono' 6 | } 7 | 8 | export default function RootLayout({ 9 | children 10 | }: Readonly<{ 11 | children: React.ReactNode 12 | }>) { 13 | return ( 14 | 15 | {children} 16 | 17 | ) 18 | } 19 | -------------------------------------------------------------------------------- /templates/nextjs/app/page.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { useEffect, useState } from 'react' 3 | 4 | export default function Home() { 5 | const [message, setMessage] = useState() 6 | 7 | useEffect(() => { 8 | const fetchData = async () => { 9 | const res = await fetch('/api/hello') 10 | const { message } = await res.json() 11 | setMessage(message) 12 | } 13 | fetchData() 14 | }, []) 15 | 16 | if (!message) return

Loading...

17 | 18 | return

{message}

19 | } 20 | -------------------------------------------------------------------------------- /templates/nextjs/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /templates/nextjs/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | } 5 | 6 | module.exports = nextConfig 7 | -------------------------------------------------------------------------------- /templates/nextjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "next dev", 4 | "build": "next build", 5 | "start": "next start", 6 | "lint": "next lint" 7 | }, 8 | "dependencies": { 9 | "hono": "^4.7.11", 10 | "next": "14.2.5", 11 | "react": "18.2.0", 12 | "react-dom": "18.2.0" 13 | }, 14 | "devDependencies": { 15 | "@types/node": "18.11.18", 16 | "@types/react": "18.0.26", 17 | "@types/react-dom": "18.0.10", 18 | "typescript": "^5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /templates/nextjs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2022", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "strict": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "noEmit": true, 14 | "esModuleInterop": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "jsx": "preserve", 20 | "incremental": true, 21 | "baseUrl": ".", 22 | "paths": { 23 | "@/*": [ 24 | "./*" 25 | ] 26 | }, 27 | "plugins": [ 28 | { 29 | "name": "next" 30 | } 31 | ] 32 | }, 33 | "include": [ 34 | "next-env.d.ts", 35 | "**/*.ts", 36 | "**/*.tsx", 37 | ".next/types/**/*.ts" 38 | ], 39 | "exclude": [ 40 | "node_modules" 41 | ] 42 | } -------------------------------------------------------------------------------- /templates/nodejs/.gitignore: -------------------------------------------------------------------------------- 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 29 | -------------------------------------------------------------------------------- /templates/nodejs/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | npm install 3 | npm run dev 4 | ``` 5 | 6 | ``` 7 | open http://localhost:3000 8 | ``` 9 | -------------------------------------------------------------------------------- /templates/nodejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "scripts": { 4 | "dev": "tsx watch src/index.ts", 5 | "build": "tsc", 6 | "start": "node dist/index.js" 7 | }, 8 | "dependencies": { 9 | "@hono/node-server": "^1.14.3", 10 | "hono": "^4.7.11" 11 | }, 12 | "devDependencies": { 13 | "@types/node": "^20.11.17", 14 | "tsx": "^4.7.1", 15 | "typescript": "^5.8.3" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /templates/nodejs/src/index.ts: -------------------------------------------------------------------------------- 1 | import { serve } from '@hono/node-server' 2 | import { Hono } from 'hono' 3 | 4 | const app = new Hono() 5 | 6 | app.get('/', (c) => { 7 | return c.text('Hello Hono!') 8 | }) 9 | 10 | serve({ 11 | fetch: app.fetch, 12 | port: 3000 13 | }, (info) => { 14 | console.log(`Server is running on http://localhost:${info.port}`) 15 | }) 16 | -------------------------------------------------------------------------------- /templates/nodejs/tsconfig.json: -------------------------------------------------------------------------------- 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 | } 17 | -------------------------------------------------------------------------------- /templates/vercel/.gitignore: -------------------------------------------------------------------------------- 1 | # dev 2 | .vercel/ 3 | .yarn/ 4 | !.yarn/releases 5 | .vscode/* 6 | !.vscode/launch.json 7 | !.vscode/*.code-snippets 8 | .idea/workspace.xml 9 | .idea/usage.statistics.xml 10 | .idea/shelf 11 | 12 | # deps 13 | node_modules/ 14 | 15 | # env 16 | .env 17 | .env.production 18 | 19 | # logs 20 | logs/ 21 | *.log 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | pnpm-debug.log* 26 | lerna-debug.log* 27 | 28 | # misc 29 | .DS_Store 30 | -------------------------------------------------------------------------------- /templates/vercel/README.md: -------------------------------------------------------------------------------- 1 | ``` 2 | npm install 3 | npm run start 4 | ``` 5 | -------------------------------------------------------------------------------- /templates/vercel/api/index.ts: -------------------------------------------------------------------------------- 1 | import { Hono } from 'hono' 2 | import { handle } from 'hono/vercel' 3 | 4 | export const config = { 5 | runtime: 'edge' 6 | } 7 | 8 | const app = new Hono().basePath('/api') 9 | 10 | app.get('/', (c) => { 11 | return c.json({ message: 'Hello Hono!' }) 12 | }) 13 | 14 | export default handle(app) 15 | -------------------------------------------------------------------------------- /templates/vercel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "vercel dev", 4 | "deploy": "vercel" 5 | }, 6 | "dependencies": { 7 | "hono": "^4.7.11" 8 | }, 9 | "devDependencies": { 10 | "vercel": "^32.4.1" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /templates/vercel/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/honojs/starter/243466b812b78e197900ccc2a3c4efa0bc924a86/templates/vercel/public/favicon.ico -------------------------------------------------------------------------------- /templates/vercel/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "skipLibCheck": true, 8 | "strict": true, 9 | }, 10 | } -------------------------------------------------------------------------------- /templates/vercel/vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "rewrites": [ 3 | { 4 | "source": "/api/(.*)", 5 | "destination": "/api" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /templates/x-basic/.gitignore: -------------------------------------------------------------------------------- 1 | # prod 2 | dist/ 3 | 4 | # dev 5 | .hono/ 6 | .wrangler/ 7 | .yarn/ 8 | !.yarn/releases 9 | .vscode/* 10 | !.vscode/launch.json 11 | !.vscode/*.code-snippets 12 | .idea/workspace.xml 13 | .idea/usage.statistics.xml 14 | .idea/shelf 15 | 16 | # deps 17 | node_modules/ 18 | 19 | # env 20 | .env 21 | .env.production 22 | .dev.vars 23 | 24 | # logs 25 | logs/ 26 | *.log 27 | npm-debug.log* 28 | yarn-debug.log* 29 | yarn-error.log* 30 | pnpm-debug.log* 31 | lerna-debug.log* 32 | 33 | # misc 34 | .DS_Store 35 | -------------------------------------------------------------------------------- /templates/x-basic/app/client.ts: -------------------------------------------------------------------------------- 1 | import { createClient } from 'honox/client' 2 | 3 | createClient() 4 | -------------------------------------------------------------------------------- /templates/x-basic/app/global.d.ts: -------------------------------------------------------------------------------- 1 | import type {} from 'hono' 2 | 3 | declare module 'hono' { 4 | interface Env { 5 | Variables: {} 6 | Bindings: {} 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /templates/x-basic/app/islands/counter.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'hono/jsx' 2 | 3 | export default function Counter() { 4 | const [count, setCount] = useState(0) 5 | return ( 6 |
7 |

{count}

8 | 14 |
15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /templates/x-basic/app/routes/_404.tsx: -------------------------------------------------------------------------------- 1 | import type { NotFoundHandler } from 'hono' 2 | 3 | const handler: NotFoundHandler = (c) => { 4 | c.status(404) 5 | return c.render('404 Not Found') 6 | } 7 | 8 | export default handler 9 | -------------------------------------------------------------------------------- /templates/x-basic/app/routes/_error.tsx: -------------------------------------------------------------------------------- 1 | import type { ErrorHandler } from 'hono' 2 | 3 | const handler: ErrorHandler = (e, c) => { 4 | if ('getResponse' in e) { 5 | return e.getResponse() 6 | } 7 | console.error(e.message) 8 | c.status(500) 9 | return c.render('Internal Server Error') 10 | } 11 | 12 | export default handler 13 | -------------------------------------------------------------------------------- /templates/x-basic/app/routes/_renderer.tsx: -------------------------------------------------------------------------------- 1 | import { jsxRenderer } from 'hono/jsx-renderer' 2 | import { Link, Script } from 'honox/server' 3 | 4 | export default jsxRenderer(({ children }) => { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | 12 |