├── .eslintrc.cjs ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── package.json └── projects ├── basic ├── app │ ├── client.ts │ ├── islands │ │ └── counter.tsx │ ├── routes │ │ ├── _renderer.tsx │ │ └── index.tsx │ ├── server.ts │ └── style.css ├── package.json ├── public │ └── .assetsignore ├── tsconfig.json ├── vite.config.ts └── wrangler.jsonc ├── blog ├── app │ ├── client.ts │ ├── components │ │ ├── button.tsx │ │ ├── header.tsx │ │ ├── time.tsx │ │ └── title.tsx │ ├── db.ts │ ├── factory.ts │ ├── islands │ │ └── contentForm.tsx │ ├── routes │ │ ├── _404.tsx │ │ ├── _error.tsx │ │ ├── _renderer.tsx │ │ ├── articles │ │ │ ├── [id].tsx │ │ │ ├── create.tsx │ │ │ └── preview.tsx │ │ └── index.tsx │ ├── server.ts │ ├── style.css │ └── utils.ts ├── blog.sql ├── package.json ├── public │ ├── .assetsignore │ └── static │ │ └── style.css ├── tsconfig.json ├── vite.config.ts └── wrangler.jsonc ├── mdx ├── app │ ├── global.d.ts │ ├── routes │ │ ├── _renderer.tsx │ │ ├── index.tsx │ │ └── posts │ │ │ └── hello.mdx │ ├── server.ts │ └── types.ts ├── package.json ├── public │ └── static │ │ └── style.css ├── tsconfig.json ├── vite.config.ts └── wrangler.jsonc ├── react ├── 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 └── tailwind ├── app ├── client.ts ├── routes │ ├── _renderer.tsx │ └── index.tsx ├── server.ts └── style.css ├── package.json ├── public └── .assetsignore ├── tsconfig.json ├── vite.config.ts └── wrangler.jsonc /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@hono/eslint-config'] 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .wrangler 3 | .mf 4 | *.tgz 5 | yarn.lock 6 | dist 7 | .hono 8 | 9 | 10 | package-lock.json 11 | 12 | # Swap the comments on the following lines if you wish to use zero-installs 13 | # In that case, don't forget to run `yarn config set enableGlobalCache false`! 14 | # Documentation here: https://yarnpkg.com/features/caching#zero-installs 15 | 16 | #!.yarn/cache 17 | .pnp.* 18 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.validate": [ 3 | "javascript", 4 | "javascriptreact", 5 | "typescript", 6 | "typescriptreact" 7 | ], 8 | "editor.codeActionsOnSave": { 9 | "source.fixAll.eslint": "explicit" 10 | }, 11 | "typescript.tsdk": "node_modules/typescript/lib" 12 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HonoX Examples 2 | 3 | This repository is containing examples using [HonoX](https://github.com/honojs/honox). 4 | 5 | ## Included Examples 6 | 7 | - [basic](./projects/basic/) - Basic example with an island. 8 | - [blog](./projects/blog/) - Blog site using Cloudflare D1. 9 | - [mdx](./projects/mdx/) - Simple blog using MDX markdown. 10 | - [tailwind](./projects/tailwind/) - Example using Tailwind CSS. 11 | 12 | ## Author 13 | 14 | Yusuke Wada 15 | 16 | ## License 17 | 18 | MIT 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hono-x-examples", 3 | "workspaces": [ 4 | "projects/basic", 5 | "projects/blog", 6 | "projects/mdx", 7 | "projects/tailwind" 8 | ], 9 | "devDependencies": { 10 | "@cloudflare/workers-types": "^4.20250224.0", 11 | "@hono/eslint-config": "^1.0.2", 12 | "@hono/vite-build": "^1.3.0", 13 | "@hono/vite-dev-server": "^0.18.2", 14 | "eslint": "^9.21.0", 15 | "typescript": "^5.7.3", 16 | "wrangler": "^3.109.3" 17 | }, 18 | "dependencies": { 19 | "hono": "^4.7.2", 20 | "honox": "^0.1.35", 21 | "vite": "^6.2.0" 22 | } 23 | } -------------------------------------------------------------------------------- /projects/basic/app/client.ts: -------------------------------------------------------------------------------- 1 | import { createClient } from 'honox/client' 2 | 3 | createClient() 4 | -------------------------------------------------------------------------------- /projects/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 | 9 |
10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /projects/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 | 13 | 14 | 15 | ) : ( 16 | <> 17 | 18 | 19 | 20 | )} 21 | 22 | {children} 23 | 24 | ) 25 | }) 26 | -------------------------------------------------------------------------------- /projects/react/app/routes/index.tsx: -------------------------------------------------------------------------------- 1 | import { createRoute } from 'honox/factory' 2 | import Counter from '../islands/counter' 3 | 4 | export default createRoute((c) => { 5 | const name = c.req.query('name') ?? 'Hono' 6 | return c.render( 7 |
8 | {name} 9 |

Hello, {name}!

10 | 11 |
12 | ) 13 | }) 14 | -------------------------------------------------------------------------------- /projects/react/app/server.ts: -------------------------------------------------------------------------------- 1 | import { showRoutes } from 'hono/dev' 2 | import { createApp } from 'honox/server' 3 | 4 | const app = createApp() 5 | 6 | showRoutes(app) 7 | 8 | export default app 9 | -------------------------------------------------------------------------------- /projects/react/app/style.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss' source('../app'); 2 | -------------------------------------------------------------------------------- /projects/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react", 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build --mode client && vite build", 7 | "preview": "wrangler dev", 8 | "deploy": "bun run build && wrangler deploy" 9 | }, 10 | "private": true, 11 | "dependencies": { 12 | "@hono/react-renderer": "^0.3.0", 13 | "hono": "^4.7.4", 14 | "honox": "^0.1.38", 15 | "react": "^19.0.0", 16 | "react-dom": "^19.0.0" 17 | }, 18 | "devDependencies": { 19 | "@cloudflare/workers-types": "^4.20250214.0", 20 | "@hono/vite-build": "^1.3.0", 21 | "@hono/vite-dev-server": "^0.18.2", 22 | "@tailwindcss/vite": "^4.0.9", 23 | "@types/react": "^19.0.10", 24 | "@types/react-dom": "^19.0.4", 25 | "tailwindcss": "^4.0.9", 26 | "vite": "^6.2.1", 27 | "wrangler": "^3.109.2" 28 | } 29 | } -------------------------------------------------------------------------------- /projects/react/public/.assetsignore: -------------------------------------------------------------------------------- 1 | index.js 2 | .vite/ -------------------------------------------------------------------------------- /projects/react/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusukebe/honox-examples/2ee31d3509d474bbe9c1d90731a8f9a29132d36d/projects/react/public/favicon.ico -------------------------------------------------------------------------------- /projects/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Bundler", 6 | "esModuleInterop": true, 7 | "strict": true, 8 | "lib": [ 9 | "DOM", 10 | "ESNext" 11 | ], 12 | "types": [ 13 | "vite/client" 14 | ], 15 | "jsx": "react-jsx", 16 | "jsxImportSource": "react", 17 | }, 18 | } -------------------------------------------------------------------------------- /projects/react/vite.config.ts: -------------------------------------------------------------------------------- 1 | import build from '@hono/vite-build/cloudflare-workers' 2 | import adapter from '@hono/vite-dev-server/cloudflare' 3 | import tailwindcss from '@tailwindcss/vite' 4 | import honox from 'honox/vite' 5 | import { defineConfig } from 'vite' 6 | 7 | export default defineConfig(({ mode }) => { 8 | if (mode === 'client') { 9 | return { 10 | build: { 11 | rollupOptions: { 12 | input: ['./app/client.ts', './app/style.css'], 13 | output: { 14 | entryFileNames: 'static/client.js', 15 | chunkFileNames: 'static/assets/[name]-[hash].js', 16 | assetFileNames: 'static/assets/[name].[ext]' 17 | } 18 | }, 19 | emptyOutDir: false 20 | }, 21 | plugins: [tailwindcss()] 22 | } 23 | } else { 24 | return { 25 | ssr: { 26 | external: ['react', 'react-dom'] 27 | }, 28 | plugins: [ 29 | honox({ 30 | devServer: { adapter }, 31 | client: { input: ['./app/style.css'] } 32 | }), 33 | tailwindcss(), 34 | build() 35 | ] 36 | } 37 | } 38 | }) 39 | -------------------------------------------------------------------------------- /projects/react/wrangler.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../node_modules/wrangler/config-schema.json", 3 | "name": "honox-examples-react", 4 | "main": "./dist/index.js", 5 | "compatibility_date": "2024-04-01", 6 | "compatibility_flags": [ 7 | "nodejs_compat" 8 | ], 9 | "assets": { 10 | "directory": "./dist" 11 | } 12 | } -------------------------------------------------------------------------------- /projects/tailwind/app/client.ts: -------------------------------------------------------------------------------- 1 | import { createClient } from 'honox/client' 2 | 3 | createClient() 4 | -------------------------------------------------------------------------------- /projects/tailwind/app/routes/_renderer.tsx: -------------------------------------------------------------------------------- 1 | import { jsxRenderer } from 'hono/jsx-renderer' 2 | import { Link } from 'honox/server' 3 | 4 | export default jsxRenderer(({ children }) => { 5 | return ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | {children} 13 | 14 | ) 15 | }) 16 | -------------------------------------------------------------------------------- /projects/tailwind/app/routes/index.tsx: -------------------------------------------------------------------------------- 1 | import { createRoute } from 'honox/factory' 2 | 3 | export default createRoute((c) => { 4 | return c.render( 5 |
6 |

Hello!

7 |
8 | ) 9 | }) 10 | -------------------------------------------------------------------------------- /projects/tailwind/app/server.ts: -------------------------------------------------------------------------------- 1 | import { showRoutes } from 'hono/dev' 2 | import { createApp } from 'honox/server' 3 | 4 | const app = createApp() 5 | 6 | showRoutes(app) 7 | 8 | export default app 9 | -------------------------------------------------------------------------------- /projects/tailwind/app/style.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss' source('../app'); 2 | -------------------------------------------------------------------------------- /projects/tailwind/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tailwind", 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build --mode client && vite build", 7 | "preview": "wrangler dev", 8 | "deploy": "$npm_execpath run build && wrangler deploy" 9 | }, 10 | "private": true, 11 | "devDependencies": { 12 | "@tailwindcss/vite": "^4.0.9", 13 | "tailwindcss": "^4.0.9" 14 | } 15 | } -------------------------------------------------------------------------------- /projects/tailwind/public/.assetsignore: -------------------------------------------------------------------------------- 1 | index.js 2 | .vite/ -------------------------------------------------------------------------------- /projects/tailwind/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "bundler", 6 | "esModuleInterop": true, 7 | "strict": true, 8 | "lib": [ 9 | "esnext" 10 | ], 11 | "types": [ 12 | "vite/client" 13 | ], 14 | "jsx": "react-jsx", 15 | "jsxImportSource": "hono/jsx" 16 | }, 17 | } -------------------------------------------------------------------------------- /projects/tailwind/vite.config.ts: -------------------------------------------------------------------------------- 1 | import build from '@hono/vite-build/cloudflare-workers' 2 | import honox from 'honox/vite' 3 | import { defineConfig } from 'vite' 4 | import tailwindcss from '@tailwindcss/vite' 5 | 6 | export default defineConfig({ 7 | plugins: [ 8 | tailwindcss(), 9 | honox({ 10 | client: { 11 | input: ['./app/style.css'] 12 | } 13 | }), 14 | build() 15 | ] 16 | }) 17 | -------------------------------------------------------------------------------- /projects/tailwind/wrangler.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../node_modules/wrangler/config-schema.json", 3 | "name": "honox-examples-tailwind", 4 | "main": "./dist/index.js", 5 | "compatibility_date": "2024-04-01", 6 | "compatibility_flags": [ 7 | "nodejs_compat" 8 | ], 9 | "assets": { 10 | "directory": "./dist" 11 | } 12 | } --------------------------------------------------------------------------------