The SQLite Explorer has been successfully migrated from server-rendered JSX with HTMX to a React SPA with Hono backend, following Val Town best practices.
project-sqlite/
├── backend/
│ └── index.http.ts # Main Hono server with API routes
├── frontend/
│ ├── components/
│ │ ├── Icons.tsx # SVG icon components
│ │ ├── Table.tsx # Query results table
│ │ ├── TablesList.tsx # Database schema browser
│ │ ├── EditorSection.tsx # SQL editor with CodeMirror
│ │ └── Separator.tsx # Panel separators
│ ├── hooks/
│ │ ├── useCodeEditor.ts # Editor state & SQL extraction
│ │ ├── useQueryExecution.ts # Query execution logic
│ │ ├── useTableSelection.ts # Table selection & persistence
│ │ └── useDownload.ts # Download functionality
│ ├── App.tsx # Main application component
│ ├── main.tsx # React entry point
│ ├── index.html # HTML template
│ ├── reset.css # CSS reset
│ └── style.css # Application styles
└── shared/
├── types.ts # Shared TypeScript types
├── sqlHelpers.ts # SQL parsing utilities
└── exportHelpers.ts # CSV/JSON export functions
✅ All original features preserved:
✅ Architecture improvements:
The backend exposes the following REST API endpoints:
GET /api/schema - Returns all tables and viewsPOST /api/query - Executes SQL query, returns resultsGET /api/download/csv?query=... - Downloads results as CSVGET /api/download/json?query=... - Downloads results as JSONGET / - Serves React applicationGET /frontend/* - Serves frontend assetsGET /shared/* - Serves shared utilitiesInitial Load
frontend/index.htmlfrontend/main.tsxTable Selection
useTableSelection hook loads saved query from localStorage OR generates default SELECT * FROM tableQuery Execution
useCodeEditor extracts statement at cursor positionuseQueryExecution sends POST to /api/queryData Export
useDownload hook triggers download from /api/download/*The app uses React hooks for state management:
backend/index.http.tsFor local development outside Val Town, you'll need to:
Replace Val Town-specific imports:
https://esm.town/v/std/sqlite → Use better-sqlite3 or Turso clienthttps://esm.town/v/std/utils → Implement file serving manuallySet up a dev server with Vite or similar
react-resizable-panels library if neededPotential improvements to consider:
/frontend/index.html is being served/api/query endpoint is accessible/api/download/* endpointsMigration completed on: 2025-11-14 Framework: React 18 + Hono 4 Status: Ready for testing