Skip to content
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

Bad practice recommended with Hono + Pages #16446

Open
Cherry opened this issue Aug 25, 2024 · 5 comments
Open

Bad practice recommended with Hono + Pages #16446

Cherry opened this issue Aug 25, 2024 · 5 comments
Assignees
Labels
content:edit Request for content edits documentation Documentation edits product:pages

Comments

@Cherry
Copy link
Contributor

Cherry commented Aug 25, 2024

Existing documentation URL(s)

https://developers.cloudflare.com/pages/framework-guides/deploy-a-hono-site/

What changes are you suggesting?

This page is encouraging users to use Hono to serve assets. This is bad practice. It'll cause an unnecessary Worker invocation (and therefore potentially additional fees for users), instead of using something like Pages Functions Routing, or _routes.json.

It's also extremely confusing to end-users why and how Pages is used here.

Additional information

No response

@Cherry Cherry added content:edit Request for content edits documentation Documentation edits labels Aug 25, 2024
@gshirescf
Copy link

gshirescf commented Sep 30, 2024

cc: @megaconfidence @craigsdennis

@megaconfidence
Copy link
Member

@yusukebe what's the best way to serve static assets using Hono and Workers Assets?

@yusukebe
Copy link
Contributor

yusukebe commented Oct 4, 2024

Hi @megaconfidence

I recommend the directory pattern.

  • Create a ./public directory in your project.
  • Add your asset files to it.
  • Set up the wrangler.toml like below.
  • /static/foo.txt will return ./public/static/foo.txt.
name = "my-worker"
main = "src/index.ts"
compatibility_date = "2024-09-19"
assets = { directory = "public" }

We (Hono contributors) also have to update the Hono docs: https://hono.dev/docs/getting-started/cloudflare-workers#serve-static-files

@yusukebe
Copy link
Contributor

yusukebe commented Oct 4, 2024

For Cloudflare Pages, we can use this doc:

https://hono.dev/docs/getting-started/cloudflare-pages

But there is one problem. This does not use C3 because it does not have a Pages template for Hono; it has only a Workers template. So in the doc, it uses create-hono directly, not wrapped by C3:

npm create hono@latest my-app

@yusukebe
Copy link
Contributor

yusukebe commented Oct 4, 2024

We (Hono contributors) also have to update the Hono docs: https://hono.dev/docs/getting-started/cloudflare-workers#serve-static-files

Updated: honojs/website#505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:edit Request for content edits documentation Documentation edits product:pages
Projects
None yet
Development

No branches or pull requests

8 participants