Recommendation on libraries for relatively small project
I am new to Hono and CFW. I want to use Cloudflare workers with Hono to convert an old website I wrote many years ago in Classic ASP to a modern framework as a learning exercise. After that, I have some other .NET apps I want to convert.
But, I'm stuck on some basics. Using ChatGPT I got a basic API working with Hono and Workers. But to my surprise, serving static content is not straight forward. I want to keep my project as simple as possible, but it seems i need to setup Cloudflare pages as well. I want to be able manage the static content and Worker code in the same project.
I also want to use templates for the HTML content. I'm familiar with Handlebars but I'm not sure that's ideal here. I want to use whatever is best and lightweight/fastest for my project.
It would also be nice to have some kind of ORM for the D1 database
Do you have any recommendations on the stack/libraries I should go with?
Are there any current tutorials you can point me to that will help me get up and running?
Thank you.
6 Replies
Hono can work with JSX, so you don't need an external template lib. For ORM you can use Drizzle, I think it works with D1 Database in the latest release.
For static resources it is recommend to use Pages as then it can easy get cached globally
For a simple website, I don't think you will require any external libs but let us know if you get into an error
For serving static content with CF pages, see this comment.
https://discord.com/channels/1011308539819597844/1012485912409690122/1265753791274156233
Hi Justin, so all I have to do is put the files in this directory and that's it? I dont' have to create a pages project or deal with any configuration, or js, or anything else?
If you put the files in
./public/static/assets
, CF pages will serve them without you needing to add them as a route in hono. You'll then reference them like <link rel="icon" href="static/assets/favicon.ico" />
.This would all be inside a hono project that you add to CF pages via a git repo.
OK, thank you. I think I have it. I locate the static files/templates inside the project, then connect the project to a remote git repo, and configure CF Pages to get the files from the repo?