Tutorials
Each tutorial builds one small, working feature from start to finish. Every step adds code to the previous one, and the last section shows the finished result. They are meant to be followed in order. For a reference to every option of a module, see its guide pages instead.
You need TypeScript and some familiarity with the libraries each tutorial uses (named below). Install commands are at the top of each page.
Build a “products” list with filters, sorting and cursor pagination. All of that state lives in the URL, from the database query to the address bar.
You will learn how to:
- share one field allow-list and URL format between the browser and the server;
- validate a filter request with the valibot schemas and render it to a Drizzle
WHERE, and switch to Kysely or Prisma; - page through results with keyset pagination (
createDrizzleKeyset+createPaginator), including previous pages; - serve a REST endpoint that answers 400 for a tampered cursor;
- keep filters, sort and cursor in the URL with
@xtandard/lib/tanstackand the compact filter encoding.
Uses: Drizzle, valibot, TanStack Router, TanStack Query.
Show supplier quotes as they arrive, in a list and in a toast, instead of waiting for all of them.
You will learn how to:
- write a producer as an async generator, or as an
AsyncChannelfed by concurrent requests; - render a stream with
useStreamandStreamRenderer, including its return value and error state; - keep only what you need with
mode,maxItemsor areducer; - track the same work in a Sonner toast with
toastStreamandtoastStreamAsync; - fake a producer with
asyncOfwhile you build and test the UI.
Uses: React, TanStack Query, Sonner.
Model a meeting room’s bookings as time ranges and find out when it is free.
You will learn how to:
- represent bookings as half-open
InstantIntervals, so back-to-back meetings don’t conflict; - detect conflicts with
overlapsandintersection; - merge busy time with
mergeIntervalsand compute free slots withdifference; - find a slot that fits a meeting with
lengthandfromStart; - classify room rates into price bands with money intervals from
@xtandard/lib/dinero, and check that the bands leave no gaps.
Uses: @js-temporal/polyfill, dinero.js.