FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
laurynas
laurynastanstackReactHonoExample
Remix of stevekrouse/reactHonoExample
Public
Like
5
tanstackReactHonoExample
Home
Code
6
backend
3
frontend
7
shared
2
.vtignore
README.md
deno.json
Branches
1
Pull requests
Remixes
4
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
/
README.md
Code
/
README.md
Search
6/13/2025
Viewing readonly version of main branch: v88
View latest version
README.md

React + TanStack + Hono Val Town Project

A modern full-stack message board app built for Val Town, showcasing the latest web development tools and patterns.

Tech Stack

Backend

  • Hono - Fast, lightweight web framework for Val Town
  • Drizzle ORM - Type-safe SQL toolkit for database operations
  • SQLite - Val Town's built-in database
  • Deno - Runtime environment on Val Town serverless infrastructure

Frontend

  • React 19 - Latest React with modern features
  • TanStack Router - Type-safe routing with code-first approach
  • TanStack Query - Powerful data synchronization for server state
  • Tailwind CSS - Utility-first CSS framework
  • TypeScript - Full type safety throughout the stack

Features

  • 💬 Real-time message board - Post and view messages instantly
  • 🎨 Modern UI - Clean Tailwind design with responsive layout
  • 🔄 Optimistic updates - Instant UI feedback with automatic rollback on errors
  • 📱 Client-side routing - Fast navigation with TanStack Router
  • 🗄️ Type-safe database - Drizzle ORM with full TypeScript integration
  • ⚡ Optimized loading - Server-side data injection for fast initial renders

Project Structure

├── backend/          # Hono server running on Val Town
│   ├── database/     # Drizzle schema, migrations, and queries
│   └── index.ts      # Main Hono application
├── frontend/         # React app running in browser
│   ├── components/   # React components
│   ├── lib/          # Utilities and hooks
│   └── router.tsx    # TanStack Router configuration
└── shared/           # Code shared between frontend and backend

API Endpoints

  • GET / - Serves the React application with initial data
  • GET /messages - Fetch all messages (JSON)
  • POST /messages - Create a new message
  • GET /public/** - Static assets (CSS, JS, etc.)

Development

This project uses Val Town's constraints:

  • No file system writes (read-only after deployment)
  • ESM imports via esm.sh for npm packages
  • Single-file bundling per route
  • Code-first routing (no file-based routing)

Key Implementation Details

TanStack Router Setup

Create val
// Uses code-first routing as recommended for Val Town const homeRoute = new Route({ getParentRoute: () => rootRoute, path: "/", component: () => <App {...window.__INITIAL_DATA__} /> });

TanStack Query Integration

Create val
// Type-safe data fetching with optimistic updates export function usePostMessage() { return useMutation({ mutationFn: (content: string) => postMessage(content), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["messages"] }); }, }); }

Drizzle Schema

Create val
// Simple, type-safe schema export const messages = sqliteTable("messages", { id: integer("id").primaryKey({ autoIncrement: true }), content: text("content").notNull(), timestamp: text("timestamp").notNull().default(new Date().toISOString()), });

This project demonstrates how to build a modern, type-safe full-stack application on Val Town using the latest tools and best practices.

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.