FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
upiuzi
upiuzistevensDemo
Remix of geoffreylitt/stevensDemo
Public
Like
stevensDemo
Home
Code
10
dailyBriefing
3
dashboard
4
dbUtils
4
importers
5
shared
1
.cursorrules
README.md
S
backstory.ts
S
memoryUtils.ts
S
populateDemo.ts
Branches
1
Pull requests
Remixes
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 miliseconds.
Sign up now
Code
/
dashboard
/
backend
/
database
/
README.md
Code
/
dashboard
/
backend
/
database
/
README.md
Search
4/15/2025
README.md

Database

This app uses Val Town SQLite to manage data. Every Val Town account comes with a free SQLite database, hosted on Turso. This folder is broken up into two files:

  • migrations.ts - code to set up the database tables the app needs
  • queries.ts - functions to run queries against those tables, which are imported and used in the main Hono server in /backend/index.ts

Migrations

In backend/database/migrations.ts, this app creates a new SQLite table reactHonoStarter_messages to store messages.

This "migration" runs once on every app startup because it's imported in index.ts. You can comment this line out for a slight (30ms) performance improvement on cold starts. It's left in so that users who fork this project will have the migration run correctly.

SQLite has much more limited support for altering existing tables as compared to other databases. Often it's easier to create new tables with the schema you want, and then copy the data over. Happily LLMs are quite good at those sort of database operations, but please reach out in the Val Town Discord if you need help.

Queries

The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.

The queries file exports functions to get and write data. It relies on shared types and data imported from the /shared directory.

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.