Skip to content

Commit 7ed8b58

Browse files
committed
temp
1 parent f45a399 commit 7ed8b58

File tree

1 file changed

+56
-40
lines changed
  • src/content/docs/workers/frameworks/framework-guides

1 file changed

+56
-40
lines changed

src/content/docs/workers/frameworks/framework-guides/hono.mdx

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,78 +11,94 @@ import {
1111
InlineBadge,
1212
Render,
1313
PackageManagers,
14+
Steps,
15+
Details,
1416
} from "~/components";
1517

16-
**Start from CLI** - scaffold a Hono project with Assets.
18+
**Start from CLI** - scaffold a full-stack app with a Hono API, React SPA and the Cloudflare Vite plugin for lightning-fast development.
1719

1820
<PackageManagers
1921
type="create"
20-
pkg="cloudflare@latest"
21-
args="my-hono-app -- --framework=hono --platform=workers"
22+
pkg="cloudflare@latest my-hono-app"
23+
args="--template=cloudflare/templates/vite-react-template"
2224
/>
25+
---
26+
27+
**Or just deploy** - create a full-stack app with Hono, React and
28+
Vite, with CI/CD and previews all set up for you.
29+
30+
[![Deploy to Workers](https://deploy.workers.cloudflare.com/button)](https://dash.cloudflare.com/?to=/:account/workers-and-pages/create/deploy-to-workers&repository=https://github.com/cloudflare/templates/tree/staging/vite-react-template)
2331

2432
## What is Hono?
2533

26-
Lightweight backend, great with Cloudflare Workers.
34+
[Hono](https://hono.dev/) is an ultra-fast, lightweight framework for building web applications, and works fantastically with Cloudflare Workers.
35+
With Workers Assets, you can easily combine a Hono API running on Workers with a SPA to create a full-stack app.
2736

28-
With Workers Assets, you can easily combine a Hono backend with a SPA to create a full-stack app.
37+
## Creating a full-stack Hono app with a React SPA
2938

30-
## Adding a React SPA to a Hono project
39+
<Steps>
40+
1. **Create a new project with the create-cloudflare CLI (C3)**
3141

32-
- run c3 if you don't have an existing hono app.
33-
- add index.html
34-
- set spa mode?
35-
- does the vite plugin just work with hono?
42+
<PackageManagers
43+
type="create"
44+
pkg="cloudflare@latest my-hono-app"
45+
args="--template=cloudflare/templates/vite-react-template"
46+
/>
47+
<Details header="What's happening behind the scenes?">
48+
Hi
49+
</Details>
3650

37-
## 1. Set up a new project
51+
2. **Develop locally with the Cloudflare Vite plugin**
3852

39-
Use the [`create-cloudflare`](https://www.npmjs.com/package/create-cloudflare) CLI (C3) to set up a new project. C3 will create a new project directory, use code from the official Hono template, and provide the option to deploy instantly.
53+
After creating your project, run the following command in your project directory to start a local development server.
54+
<PackageManagers type="run" args="dev" />
55+
<Details header="What's happening behind the scenes?">
56+
Hi
57+
</Details>
4058

41-
To use `create-cloudflare` to create a new Hono project with <InlineBadge preset="beta" /> Workers Assets, run the following command:
59+
3. **Deploy your project**
4260

43-
<PackageManagers
44-
type="create"
45-
pkg="cloudflare@latest my-hono-app"
46-
args={"--framework=hono --platform=workers"}
47-
/>
61+
Your project can be deployed to a `*.workers.dev` subdomain or a [Custom Domain](/workers/configuration/routing/custom-domains/), from your own machine or from any CI/CD system, including [Cloudflare's own](/workers/ci-cd/builds/).
4862

49-
<Render
50-
file="c3-post-run-steps"
51-
product="workers"
52-
params={{
53-
category: "web-framework",
54-
framework: "Hono",
55-
}}
56-
/>
63+
The following command will build and deploy your project. If you are using CI, ensure you update your ["deploy command"](/workers/ci-cd/builds/configuration/#build-settings) configuration appropriately.
5764

58-
After setting up your project, change your directory by running the following command:
65+
<PackageManagers type="run" args={"deploy"} />
5966

60-
```sh
61-
cd my-hono-app
62-
```
67+
</Steps>
6368

64-
## 2. Develop locally
69+
## Adding a SPA to an existing Hono project
6570

66-
After you have created your project, run the following command in the project directory to start a local server. This will allow you to preview your project locally during development.
71+
While you could use whatever framework you like, this guide will use [React](https://reactjs.org/) with the Cloudflare Vite plugin as an example.
6772

68-
<PackageManagers type="run" args={"dev"} />
73+
<Steps>
74+
1. Install React , vite (dev), plugin-react-swc,
75+
@cloudflare/vite-plugin-cloudflare
6976

70-
## 3. Deploy your project
77+
2. sett up vite config with react plugin +
78+
cloudflare
79+
80+
3. set up wrangler config so that assets point to the right
81+
directory
82+
83+
4. create index.html and main.tsx
84+
85+
5. add something in main.tsx that
86+
calls a hono endpoint
87+
88+
</Steps>
7189

7290
Your project can be deployed to a `*.workers.dev` subdomain or a [Custom Domain](/workers/configuration/routing/custom-domains/), from your own machine or from any CI/CD system, including [Cloudflare's own](/workers/ci-cd/builds/).
7391

7492
The following command will build and deploy your project. If you are using CI, ensure you update your ["deploy command"](/workers/ci-cd/builds/configuration/#build-settings) configuration appropriately.
7593

7694
<PackageManagers type="run" args={"deploy"} />
7795

96+
## Adding a Hono backend to an existing SPA
97+
98+
If you've got a static app that you r
99+
78100
---
79101

80102
## Bindings
81103

82104
Your Hono application can be fully integrated with the Cloudflare Developer Platform, in both local development and in production, by using product bindings. The [Hono documentation](https://hono.dev/docs/getting-started/cloudflare-workers#bindings) provides information about configuring bindings and how you can access them.
83-
84-
## Static assets
85-
86-
You can serve static assets in your Hono application by [placing them in the `./public/` directory](https://hono.dev/docs/getting-started/cloudflare-workers#serve-static-files). This can be useful for resource files such as images, stylesheets, fonts, and manifests.
87-
88-
<Render file="workers-assets-routing-summary" />

0 commit comments

Comments
 (0)