FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
stevekrouse

stevekrouse

reactHonoExample

Example with client-side React & Hono server
Public
Like
5
reactHonoExample
Home
Code
4
backend
3
frontend
5
shared
1
README.md
Branches
3
Pull requests
Remixes
21
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
backend
/
README.md
Code
/
backend
/
README.md
Search
2/25/2025
Viewing readonly version of main branch: v185
View latest version
README.md

Backend

This folder contains all backend-only code in this project. It's broken up into:

  • index.ts - this is the entrypoint for this whole project
  • database/ - this contains the code for interfacing with the app's SQLite database table

Hono

This app uses Hono has the a API framework. You can think of Hono as a replacement for ExpressJS that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like Flask or Sinatra, respectively.

Serving assets to the frontend

This HTML server is responsible for serving all static assets to the browser to render the app, including HTML, JavaScript (including all client-side React), CSS, and even the favicon SVG.

In a normal server environment, you would likely use a middleware like this one to serve static files. Some frameworks or deployment platforms automatically make any content inside a public/ folder public.

However in Val Town you need to handle this yourself, and it can be suprisingly difficult to read and serve files in a Val Town Project. This template uses helper functions from @stevekrouse/utils/serve-public, which handle reading project files in a way that will work across branches and forks, automatically transpiles typescript to javascript, and attempts to handle content-types and various .tsx vs .js confusions.

As of this writing Val Town only supports text files, which is why the favicon is an SVG and not an .ico or any other binary image format. If you need binary file storage, check out Blob Storage.

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.