-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Create Hono + Workers Assets doc, update Pages doc #20982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/content/docs/workers/frameworks/framework-guides/hono.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| pcx_content_type: how-to | ||
| title: Hono | ||
| head: [] | ||
| description: Create a Hono application and deploy it to Cloudflare Workers with Workers Assets. | ||
| --- | ||
|
|
||
| import { | ||
| Badge, | ||
| Description, | ||
| InlineBadge, | ||
| Render, | ||
| PackageManagers, | ||
| } from "~/components"; | ||
|
|
||
| In this guide, you will create a new [Hono](https://hono.dev/) application and deploy to Cloudflare Workers (with the new [<InlineBadge preset="beta" /> Workers Assets](/workers/static-assets/)). | ||
|
|
||
| ## 1. Set up a new project | ||
|
|
||
| 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. | ||
|
|
||
| To use `create-cloudflare` to create a new Hono project with <InlineBadge preset="beta" /> Workers Assets, run the following command: | ||
|
|
||
| <PackageManagers | ||
| type="create" | ||
| pkg="cloudflare@latest my-hono-app" | ||
| args={"--framework=hono --platform=workers"} | ||
| /> | ||
|
|
||
| <Render | ||
| file="c3-post-run-steps" | ||
| product="workers" | ||
| params={{ | ||
| category: "web-framework", | ||
| framework: "Hono", | ||
| }} | ||
| /> | ||
|
|
||
| After setting up your project, change your directory by running the following command: | ||
|
|
||
| ```sh | ||
| cd my-hono-app | ||
| ``` | ||
|
|
||
| ## 2. Develop locally | ||
|
|
||
| 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. | ||
|
|
||
| <PackageManagers type="run" args={"dev"} /> | ||
|
|
||
| ## 3. Deploy your project | ||
|
|
||
| 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/). | ||
|
|
||
| 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. | ||
|
|
||
| <PackageManagers type="run" args={"deploy"} /> | ||
|
|
||
| --- | ||
|
|
||
| ## Bindings | ||
|
|
||
| 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. | ||
|
|
||
| ## Static assets | ||
|
|
||
| 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. | ||
|
|
||
| <Render file="workers-assets-routing-summary" /> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.