JavaScript & web
JavaScript, TypeScript, React, Vue, CSS and static sites. 98 posts, newest first. All topics
Building and publishing a TypeScript library with Vite library modePackage a TypeScript library with Vite 8 library mode: ESM output, external dependencies, .d.ts files from tsc, an exports map, and testing the tarball before publishing.
Vue 3 Frameworks in 2026, and What Changed in AstroWhere Nuxt, Quasar, VitePress, Pinia and Vue Router stand in late 2026, what Vite 8 changed under them, and the Astro 6 and 7 features this blog runs on.
Vue 3 Six Years On: What Changed from 3.0 to 3.6Vue 3.0 shipped in September 2020. What each minor release added since, from script setup and defineModel to 3.5's reactivity rewrite and 3.6's Vapor Mode.
Maintaining a Legacy PHP CodebaseWhat it takes to keep the YellowSheet PHP site running, including upgrade attempts, Stripe, crons, tests and migrations.
Rebuilding FriendlyUser: A Three.js Homepage and a Starlight BlogThe homepage is now a scroll-driven three.js city built from my career and every post on this blog, and the blog itself moved to Astro Starlight without changing a single post URL. Here is what changed, with before and after recordings.
Web Streams in Node.js: ReadableStream, TransformStream and pipeToUse WHATWG streams in Node.js 24: create and iterate streams, split lines with TransformStream, parse fetch bodies, convert to Node streams, handle backpressure.
Explicit resource management in TypeScript with using and await usingHow using and await using work in TypeScript: Symbol.dispose, DisposableStack, tsconfig settings, Node 24 support, plus temp directory and SQLite transaction examples.
Page animations with the View Transitions APIAnimate DOM updates and page navigations: startViewTransition, view-transition-name, the pseudo-element tree, cross-document opt-in and reduced motion.
The CSS :has() selector: styling parents and siblings without JavaScriptPractical :has() patterns: form validation states, cards with images, previous-sibling and quantity queries, plus the selector's rules, performance notes and support.
CSS size queries: components that respond to their own widthUse CSS container queries, container-type, named @container rules and cqi units to build a card that changes layout based on its slot, not the viewport.
Timeouts and cancellation for fetch with AbortSignalfetch has no timeout option. Use AbortController, AbortSignal.timeout and AbortSignal.any to cancel requests, tell timeouts from aborts, and clean up in React.
Running TypeScript directly in Node.js with type strippingNode 22.18+ and 23.6+ run .ts files by erasing type annotations. What syntax works, what doesn't, the tsconfig settings to match, and why you still need tsc.
Template literal types in TypeScript: typed routes and event namesUse template literal types and infer to pull params out of route strings like /users/:id, build typed event names, and know where the type checker gives up.
Branded types in TypeScript: keeping IDs and units apartUse branded types to stop TypeScript mixing up user IDs and order IDs, or cents and dollars: constructor functions, type guards, JSON and Zod's .brand().
Validating untrusted input at runtime with Zod 4Use Zod 4 schemas to validate request bodies and environment variables in TypeScript: z.infer, safeParse, coercion, transforms and readable error output.
Discriminated unions and exhaustive checks in TypeScriptModel request states and webhook events as discriminated unions, narrow them by a tag field, catch missing cases with never, and parse unknown JSON into a union.
The satisfies operator in TypeScript: checking values without widening themHow satisfies checks an object against a type while keeping its precise inferred type, with config maps, Record keys, as const satisfies and the gotchas.
WebAssembly for web developers: what it's good at and when to skip itWhat WebAssembly gives a web app (fast compute, reuse of C, C++ and Rust code, a sandbox) and what it costs, with a minimal module called from JavaScript.
Byte buffers in Deno with @std/io BufferHow the Buffer class from @std/io works in Deno: writing and reading bytes, filling it from a file, and when to use web streams instead.
WebSockets in Deno: an echo server and clientBuild a WebSocket echo server in Deno with Deno.serve and Deno.upgradeWebSocket, and connect to it with the built-in WebSocket client.
Subscribing a customer to a Clover recurring plan with PHPUse Clover's sandbox APIs from PHP to tokenize a card, create a customer with a card on file, look up a tax rate, and subscribe them to a recurring plan.
Five ways to add search to a website: Algolia, Fuse.js, Google, PHP and PagefindWorking examples of site search with Algolia, Fuse.js in React, Google Programmable Search, a PHP and MySQL query, and Pagefind for static sites.
Keeping an element above the fold in React with refs and getBoundingClientRectMeasure where an element ends up on the page with a React ref and getBoundingClientRect, then shift it up with a negative top offset so it stays above the fold.
Getting started with react-spring: useSpring and useTrail examplesThree small react-spring examples (a fade-in, a slide and a staggered trail) using the current @react-spring/web package and the .to() API.
Building a custom WordPress theme: files, the Loop, and publishingNotes from building a rough Tailwind-styled WordPress theme, covering the theme files, a post-card Loop, its bugs, and where to publish it.
An endless road animation for a car in React and CSSMake a car look like it is driving forever by scrolling dashed road markings with a CSS keyframe animation inside a small React component.
Removing carrier-deactivated numbers with Twilio's Deactivations API and BullMQA daily BullMQ job in Node.js that downloads Twilio's list of carrier-deactivated US numbers and removes them from your subscriber list.
An IP address lookup API in LaravelA small Laravel JSON API that validates IP addresses, looks them up through an external service with the HTTP client, and caches the results with Eloquent.
Mermaid diagrams from text: flowcharts, sequence, Gantt, class, state and ER examplesWrite flowcharts, sequence diagrams, Gantt charts, class, state and ER diagrams as text with Mermaid, plus theming, click links, and rendering in pages or the CLI.
Finding and removing broken links with the Fetch APIUse fetch() HEAD requests to find links that return 4xx or 5xx errors, remove them from a page in the browser, or check them from Node.js.
What Laravel is and how to start a project with itA short introduction to Laravel, the PHP web framework, covering what it includes, how to create a new app, and how routes work.
How to make images load faster on a websitePractical ways to cut image weight on a web page, covering format choice, compression, srcset and sizes, lazy loading, layout shift and CDNs.
Add an "Open in Overleaf" button in HTML or ReactBuild a link that opens a public .tex file as a new Overleaf project, as a plain HTML anchor, a Python helper, and a reusable React component.
Porting my LaTeX diagrams site from Saber to NextraHow I moved my LaTeX diagrams site from the Vue-based Saber generator to Nextra on Next.js, with the config files I used and the migration steps.
Clustering map markers in React Native with superclusterBuild a clustered MapView for react-native-maps with supercluster: group nearby markers, show a count bubble, and zoom in when a cluster is tapped.
Add a Google Map with a marker to a web page using the Maps JavaScript APIGet an API key, load the Google Maps JavaScript API, and render a map with an advanced marker in a plain HTML page.
Networked Phaser game, part II: the browser clientThe Phaser 2 browser client for a multiplayer pirate ship game: input, Socket.IO sync with the Node server, interpolation, collisions and health.
Multiplayer Phaser game, part I: the Node.js and Socket.IO serverHow the server for my Phaser pirate-ship game tracks players, bullets, health packs and driftwood, and broadcasts state with Express and Socket.IO.
WebAssembly for AR and VR on the web: where it fits with WebXRWhat WebAssembly does and doesn't do for browser AR/VR: how it works with WebXR and WebGL, which engines export to it, and the gotchas to plan for.
Downloading League of Legends match history with Deno and the Riot APIA Deno script that pages through a player's League of Legends match IDs with Riot's match-v5 API, plus why custom games don't show up.
A React image component with a loading skeleton and fallback imageBuild a React image component that shows a shimmer skeleton while the image loads and swaps to a fallback image if it fails, without error loops.
Node.js 18: built-in fetch and the node:test runnerTwo Node.js 18 additions that replace npm packages: a global fetch() enabled by default, and the built-in node:test test runner.
Testing in Deno with Deno.test and @std/assertWrite and run tests in Deno with Deno.test and @std/assert: async tests, test steps, permissions, filtering, parallel runs and coverage.
Building a responsive price card component in ReactHow I built a React price card with an image, nightly price, host and total, then made it responsive with a media query and added a hover zoom in CSS.
Building a command-line app in TypeScript with Commander.jsSet up a TypeScript project, define commands, arguments and options with Commander.js, compile with tsc, and install the result as a runnable CLI.
Building a Caesar cipher component in Vue 3A small Vue 3 single-file component that encrypts and decrypts text with a Caesar shift, including handling negative and large shift values.
Why JavaScript's Date is painful, and what to use insteadWhere the built-in Date object trips you up with time zones and parsing, and how Intl, Temporal, Moment Timezone and date-fns-tz handle the same conversions.
CSS-in-JS vs plain CSS in React, with styled-components examplesThe trade-offs between runtime CSS-in-JS and plain CSS or CSS Modules in React, with working styled-components examples and its 2025 maintenance-mode status.
Fade elements in on scroll with CSS transitions and react-intersection-observerUse the useInView hook from react-intersection-observer to add a CSS class when an element scrolls into view, and animate it with a CSS transition.
CSS animations in Vue 3: keyframes, class bindings and TransitionGroupAnimate Vue 3 components with CSS keyframes, toggle animations with class bindings, and animate list items with TransitionGroup and its CSS classes.
Static site generators compared: Jekyll, Hugo, Gatsby, Next.js, Eleventy, VuePress, Astro and GridsomeWhat a static site generator does, and the trade-offs between Jekyll, Hugo, Gatsby, Next.js, Eleventy, VuePress/VitePress, Astro and Gridsome.
Checking, requesting, and revoking permissions in DenoHow Deno's permission flags work and how to check, request, and revoke permissions at runtime with the built-in Deno.permissions API.
Getting started with Remix: loaders, actions, and the move to React RouterHow Remix's loaders, actions, and nested routes work, how it compares to Next.js, and how to start the same app today with React Router framework mode.
The deno CLI: run, fmt, lint, check, bundle and compileA tour of the deno CLI: running TypeScript with permission flags, then formatting, linting, type-checking, bundling and compiling a small script.
Running C numerical code in the browser with WebAssembly and EmscriptenCompile a C dot-product function to WebAssembly with Emscripten, pass Float64Array data through Wasm memory, and see where Wasm fits for scientific code.
React class components: state, props, events and lifecycle methodsHow to write React class components with state, props, event handlers, lifecycle methods and TypeScript types, and when you still need one.
Next.js basics: rendering modes, a TypeScript starter app and deploying to VercelWhat Next.js adds on top of React, how to create a TypeScript app with the App Router, the built-in components worth using, and how to deploy it to Vercel.
Sharing state across React components with ContextHow to use createContext and useContext to share state without prop drilling, with counter, theme toggle and viewport-size examples, and how context re-renders work.
React function components: props, hooks, events and TypeScriptWrite React function components, manage state and effects with hooks, handle events and forms, and type props in TypeScript.
React UI libraries and app basics: MUI, React-Bootstrap, routing, Redux and testsAdd MUI or React-Bootstrap to a Vite React app, then wire up controlled forms, React Router, Redux Toolkit, Vitest tests and a Vercel deploy.
HTTP requests in Deno with fetchMake HTTP requests in Deno with the built-in fetch: GET and POST, error handling, timeouts, streaming a download to disk, and Deno-specific options.
Converting React inline style objects to CSS classes with ChatGPTWhy moving React inline style objects into CSS classes helps, and how I used ChatGPT to turn a camelCase style object into a CSS rule.
Page transitions in Next.js: Motion in the Pages Router, ViewTransition in the App RouterFade between routes in Next.js with Motion's AnimatePresence in the Pages Router, or React's ViewTransition component in the App Router.
The Deno standard library: using @std packages from JSRWhat the Deno standard library is, how to install its @std packages from JSR, and examples from @std/fs, @std/http, @std/datetime and @std/uuid.
SVG wave hero section for an investing homepage with Vue and VuesaxGenerating SVG wave paths in a Vue component, and building an animated wave hero section for an investing blog homepage with Nuxt 2 and Vuesax.
HTTP in Deno: servers with Deno.serve, requests with fetch, and @std/httpHow to build HTTP servers in Deno with Deno.serve, make requests with fetch, stream files, and serve static directories with @std/http.
How I style SVG icons in Next.js: inline fetch plus CSS modulesA small React component that fetches an SVG file and inlines it, so a CSS module can recolour the icon's paths when it is toggled.
Dumb bug fixes that shouldn't have workedA running list of bug fixes that shouldn't have worked but did, starting with a PHP 5.2 session bug fixed by re-uploading the same file to cPanel.
Building a scripted chat bot in React with react-simple-chatbotA small scripted "about me" chat bot built with react-simple-chatbot, where each step shows a message or a set of options that decide the next step.
What package.json does in a Node.js project, with an Express exampleThe main package.json fields (name, version, scripts, dependencies, devDependencies) and how to add a start script for a small Express server.
Parsing and writing YAML in Deno with @std/yamlHow to parse, edit and write YAML in Deno with @std/yaml from JSR, including typing the parsed result and a couple of YAML gotchas.
Building a URL shortener dapp with Solidity, Nuxt and ethersHow my Nuxt URL shortener stored links in a Solidity contract, created them through MetaMask with ethers.js, and redirected short IDs to the stored URL.
React Navigation basics: stacks, params, tabs, deep links and transitionsSet up React Navigation 7 in a React Native app, pass params between screens, nest a stack in tabs, handle deep links and change screen transitions.
Tracking IPFS files with a Solidity contract and a Drizzle React tableAn old dapp of mine: a Solidity contract that records IPFS hashes and tags per owner, a simple sign-up contract, and a Drizzle React table that lists the files.
A simple collapsible component in React and TypeScriptA small React function component that shows or hides its content when you click the header, with a CSS-only caret and no icon library.
Astrodon: a Tauri-based desktop app framework for Deno (unmaintained)What Astrodon was, how its webview windows and Deno messaging worked, why it no longer runs, and what to use for Deno desktop apps instead.
Building a small web server in Deno with Pogo: routes, static files and JSXUse Pogo, a hapi-style Deno web framework, to define routes, serve static files with h.directory() and render HTML from JSX.
Getting started with Fresh 2 in Deno: routes, handlers and islandsCreate a Fresh 2 app in Deno and add a file-based route with a data handler, a JSON API route and an interactive Preact island.
Building a command-line app in Deno with cacUse the cac CLI library from npm in Deno to define commands and options, print help and version output, and reject unknown commands.
Desktop automation in Deno with autopilot: mouse, keyboard and screenshotsHow the autopilot module drives the mouse, keyboard and screen from Deno through Rust FFI, with a working example and its permission flags.
Build a to-do list with Next.js API routes and Neon PostgresA Next.js to-do app with an MUI frontend, SWR data fetching, Pages Router API routes, and a Neon Postgres database accessed through node-postgres.
Setting up a VuePress 1 site with vuepress-theme-coolInstall VuePress 1 and vuepress-theme-cool, configure KaTeX, PlantUML and admonition plugins, and run a local documentation site.
vuepress-theme-cool, a VuePress 1 theme with Mermaid, charts and admonitionsHow vuepress-theme-cool extends the VuePress 1 default theme with Mermaid diagrams, a pros/cons component, Chart.js charts, sortable tables and admonitions.
Async JavaScript: promises, async/await and fetchHow promises and async/await work in JavaScript, plus making HTTP requests with fetch, handling errors, cancelling with AbortController and caching responses.
Running an Express server in a Docker containerWrite a Dockerfile for a small Express app, build the image, and run it with the port mapped to your machine.
Install Node.js and run your first Express serverInstall Node.js on Windows, macOS or Linux, then build a minimal Express 5 server with a start script and static file hosting.
Introduction to JavaScript: a free ebook on JS, Node.js and promisesAn introductory ebook on JavaScript, Node.js and asynchronous programming, written in LaTeX and published on Amazon KDP, with a free PDF copy.
Overview of corporate landing page done in react with microsoft fabric uimaking a corporate landing page in react
Using remotion for game highlightsAs I hit titan in erbs I wanted to make a video of the highlights
Upgrading from material v4 to mui v5Updating material ui components to the latest version
Adding search to static sites with pagefindSearching for content using pagefind, I will cover how I added it to my static site.
How to consume twilio conversations mediaA simple explaination of how I consume twilio conversation media
Extracting types automatically from typescript-axios openapi generatorMy Thoughts on what todo with jcenter/bintray going down.
How to use resolutions in package.jsonUsing resolutions in package.json
Screenshot utility for mobile appsThis covers how to take screenshots of your mobile app using the ios simulator or android.
How to add tags to astroHow I implemented tags for my blog
How to make a show more component in reactHow I implemented tags for my blog
Updating Vuepress Theme CoolVuepress-theme-cool 1.7
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)