• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
laurynas

laurynas

tanstackReactHonoExample

Remix of stevekrouse/reactHonoExample
Public
Like
7
tanstackReactHonoExample
Home
Code
6
backend
3
frontend
7
shared
2
.vtignore
README.md
deno.json
Branches
1
Pull requests
Remixes
6
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.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.