Skip to content

Latest commit

 

History

129 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Waypoint

Next 16 Airline "Waypoint"

An airline booking demo, from flight search to a stored trip, that demonstrates Instant Navigations in Next.js 16.4.

Live demo →


The architecture follows the Next.js App Architecture skill and the Component Architecture for React Server Components blog post.

Features

  • Cache Components cache each query with 'use cache', name the data with cacheTag, and set its lifetime with cacheLife. Search results and flight offers use 'use cache: remote' so serverless instances share one cache, and the active traveler is read with 'use cache: private'.
  • Partial Prefetching prefetches one shared App Shell per route. The link to the next booking step uses prefetch={true}, which also resolves its cached offer.
  • prefetch() and navigation() are awaited in the components that render trips, holds, and flight lists, which moves those reads to a per-link prefetch or to the navigation while keeping them cached.
  • Server Functions hold seats, confirm, and cancel trips on the server, and invalidate only the tags they change with updateTag.
  • React Compiler memoizes components and hooks automatically, so the code needs no manual useMemo or useCallback.
  • View Transitions animate content as it streams in, while the header, tab bar, and demo toolbar stay in place.
  • Async React keeps the UI interactive during server work with Suspense, useOptimistic, and useTransition.

How the data loads

Each read is cached differently and arrives at a different stage of a navigation.

Read How it is cached When it arrives
Airports and destinations 'use cache' In the static shell
Offer, seats, prices 'use cache: remote', tagged With the prefetch
Your trips and your hold 'use cache' per session, after unstable_prefetch() With a per-link prefetch
Flight list, who holds what 'use cache', after unstable_navigation() On the navigation
Seats left Uncached On every request

Holding a seat updates only the seat map's tag, so the flight list is not recomputed.

Getting started

Waypoint runs on Postgres and on a Next.js 16.4 canary, which unstable_prefetch() and unstable_navigation() need. Set DATABASE_URL in .env.local, then:

pnpm install
pnpm run prisma.push
pnpm run prisma.seed
pnpm run dev

Open http://localhost:3000 in your browser. You can browse the data with pnpm run prisma.studio, or wipe and re-seed the database with pnpm run prisma.reset.

Run locally without Postgres

Drop this prompt into your agent to swap the datasource for SQLite:

Set up Waypoint to run locally on SQLite instead of Postgres. Keep both database adapter stacks installed so the production Postgres setup remains available. Swap provider = "postgresql" to provider = "sqlite" in prisma/schema.prisma. Replace @prisma/adapter-pg with @prisma/adapter-better-sqlite3 in lib/db.ts and prisma/seed.ts, using new PrismaBetterSqlite3({ url }) where url is process.env.DATABASE_URL with the file: prefix stripped, and skip normalizeDatabaseUrl for file URLs in prisma.config.ts. Write DATABASE_URL=file:./prisma/dev.db to .env.local, then run pnpm run prisma.push and pnpm run prisma.seed.

The schema is otherwise identical, so the rest of the app behaves the same as production.

Testing

The end-to-end tests use @next/playwright with the instant() API to assert that the App Shell renders immediately and that navigations stay instant, and they run in CI.

pnpm test:e2e

Static checks:

pnpm lint
pnpm typecheck

Stack

License

MIT

About

An airline booking demo exploring Cache Components, Partial Prefetching, and the prefetch() and navigation() APIs with Next.js 16.4, React 19, Tailwind CSS v4, and Prisma.

Topics

Resources

Stars

10 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages