Integrating the SWR library with a type-safe API client
incident.io replaced its homegrown useFetchData hook with SWR (stale-while-revalidate) in its React dashboard, while keeping the type safety of its OpenAPI-generated TypeScript client. Rather than code-generating a hook per endpoint, they wrote a single generic useAPI hook. It constrains the API name to client methods excluding BaseAPI utilities, then uses conditional types, Parameters and Awaited<ReturnType> to infer request and response types. Using [api, request] as the cache key gives consistent shared caching and prevents key collisions, so one line like useAPI("customFieldsList", undefined) is fully type-checked.
Related posts
- How we built it: incident.io Status Pages
incident.io mediumAdeptincident.io built its Status Pages product in three months on Vercel and Next.js, using Incremental Static Regeneration with per-fetch revalidate times (e.g. 30s) so the backend serves only a couple of requests per minute regardless of traffic spikes. Pages are pre-built via generateStaticParams, added on demand when created, and refreshed with stale-while-revalidate, while the client uses the SWR library with a 10s refreshInterval, revalidateOnFocus and server-rendered fallbackData for live updates. Server rendering is pinned to Vercel's Dublin region next to the API, and live-reload requests are proxied through Next rewrites. The main pain point was hydration mismatches from relative times and locale/time-zone formatting, handled with explicit luxon zones/locales and lint rules against unguarded "now".
- Introducing @neon/sdk, our new TypeScript client for the Neon API
Neon mediumAdept
@neon/sdk is a fetch-based, zero-dependency, ESM-only TypeScript client for the Neon API, replacing the axios-based @neondatabase/api-client. It has two layers: a raw surface generated from Neon's OpenAPI spec with Hey API, exposing every endpoint as a tree-shakeable function, and an ergonomic client that adds retries, readiness polling of background operations, pagination, errors as values and multi-step workflows. Examples include createAndConnect for projects and branches, snapshot restore with a preview callback that commits or rolls back, and cross-organization project transfer. Neon recommends it over the MCP server and CLI for programmatic integration such as CI/CD and platform provisioning, and the old client is not being deprecated.
- Using React Query with Next.js App Router and Supabase Cache Helpers
Supabase mediumAdeptReact Query can be paired with supabase-js in a Next.js App Router app by wrapping the root layout in a client-side QueryClientProvider and creating typed browser and server Supabase clients via @supabase/ssr. Supabase Cache Helpers generate query keys automatically from supabase-js queries, so one reusable query function can be prefetched in a server component and hydrated through HydrationBoundary, letting the client render without a loading state, or fetched purely client-side. The recommendation is to reach for React Query with Server Components only when migrating an existing React Query app or when it covers needs the framework doesn't; otherwise start with the framework's own data fetching.
- Build a serverless API using Cloudflare Workers, Drizzle ORM, and Neon
Neon mediumAdept
A step-by-step setup for a serverless TypeScript API on Cloudflare Workers that uses Hono for routing, Drizzle ORM for schema definition and migrations, and Neon serverless Postgres for storage. It scaffolds a Worker with create-cloudflare, defines a products table in TypeScript, and uses drizzle-kit to generate SQL migrations. Migrations run through a postgres.js script capped at a single connection so they execute in order. The Worker queries Neon over HTTP via @neondatabase/serverless, is deployed with wrangler, and gets its DATABASE_URL from Cloudflare's Neon integration instead of manually configured secrets.
- Enhancing the Mock Server: A User Interface Approach
Zalando Engineering mediumAdeptZalando's team built a UI on top of mirage.js so product managers and designers can switch which mocked response each API endpoint returns on a staging build, without code changes or redeploys. A React Context provider re-instantiates the mock server on demand, and the selected scenario is kept in session storage under an app-unique key so it survives the page reload that loading a new data set requires. The approach covers edge cases like stale or missing data, but it complements rather than replaces unit and contract tests, and the frontend-defined mocks must be kept in sync with the backend schema. A generalized version now ships as an internal NPM module.