RSSAmplifier

Blog

Colin McDonnell @colinhacks

Founder of Bagel Health, creator of Zod, poptimist, movie buff. Wanna go to Taco Bell?

colinhacks.comRSS feed ↗14 posts

Latest posts

Introducing Zod Codecs

Zod 4.1 introduced a new z.codec() API for defining bi-directional transformations in Zod. The problem with transforms Zod's .transform() method is great for one-way data conversion: const stringToNumber = z.string().transform(val => parseFloat(val)); stringToNumber.parse("42"); // 42 But what if you need to go both ways? Say, you're storing dates as ISO strings in a database but want to work with…

Making AI resources auto-discoverable via package.json

I propose the following convention for JavaScript libraries to make their AI resources auto-discoverable via package.json. { // package.json "llms": "https://docs.cool-library.com/llms.txt", "llmsFull": "https://docs.cool-library.com/llms-full.txt", "mcpServer": "https://mcp.cool-library.com", } I've implemented this in Zod and encourage my fellow library authors to do the same. Moreover, I…

Live types in a TypeScript monorepo

EDIT: A previous version of this post recommended publishConfig , operating under the mistaken belief that it could be used to override "exports" during npm publish . As it turns out, npm only uses "publishConfig" to override certain .npmrc fields like registry and tag , whereas pnpm has expanded its use to override package metadata like "main" , "types" , and "exports" . There are a number of…

An email regex for reasonable people

I maintain Zod, which is a schema library. Zod lets people declare an email schema like this: import {z} from 'zod'; z.string().email(); A lot of people think every technically valid email address should pass validation by that schema. I used to think that too. Over the years I've merged several PRs to make the email regex more "technically correct". Most recently, I merged a PR that adds support…

From README to documentation site in 10 minutes

Spoiler alert: GitHub Pages and GitHub actions are not involved. I recently set out to build a proper documentation site for Zod with a short and eminently reasonable list of goals: The site should be generated from the README. Zod's README.md is the "source of truth". The site should automatically update whenever the master branch is updated. I didn't want to worry about building or maintaining a…

Building an end-to-end typesafe API — without GraphQL

In the mid-2010s, the pendulum of web development swung massively in the direction of increased type safety. First, we all switched back to relational DBs after recovering from an embarrassingly long collective delusion that NoSQL was cool. Then TypeScript started its meteoric rise after years of quiet development. Shortly thereafter GraphQL was announced and quickly became the de facto way to…

Why Zod 2 isn't leaving beta

Zod's v2 has been in beta since September 2020 (around 3 months as of this writing). The people are starting to talk. The background The reason Zod 2 has been in beta for so long (well, one of the reasons anyway!) is that I’ve been increasingly unsatisfied with Zod’s implementation of transformers. Transformers are a mechanism within Zod to convert data from one type to another. For the sake of…

Next.js, nested routes, and the war on SPAs

Edit: 2022 The issues described here have been largely solved by layouts in Next.js 13. I recently set out to implement a single-page application (SPA) on top of Next.js. To clarify, I'm using the term "SPA" in a very specific way. I'm referring to the "classical" SPA model: an application that handles all data fetching, rendering, and routing entirely client-side. Turns out, Next.js does not make…

Building a single-page application with Next.js and React Router

Update 2023 — Updated for Next.js 13, React Router 6, and React 18. Update 2022 — Next.js 13 now supports nested routes via the /app directory. However, it requires a server to render React Server Components, and thus doesn't qualify as a "single-page application" as defined in this post. I recently set out to implement a single-page application (SPA) on top of Next.js. To clarify, I'm using the…

Authenticated server-side rendering with Next.js and Firebase

**Update: November 29, 2020** > > I have an idea for a SaaS product related to Next.js and authentication, and I'm looking for a co-founder! Ideally you'd be intimately familiar with Next.js, TypeScript, and SQL, and perhaps have some previous entrepreneurial experience. I'm an open-source maintainer and a previous YC founder, and I feel strongly about finding the right partner before starting a…

Sponsor pools: a new funding model for open source software

Check out the HN discussion here . This article has been translated into Japanese and Russian . The existing open-source funding models don't work well for small projects. Big projects — operating systems, frameworks, CMSs, or fully self-hostable applications — are in a privileged position to extract more value from their users, especially corporate ones. Since entire APIs and products are built…

Why you shouldn't use @emotion/core

A maintainer of Emotion published a very thoughtful response to a version of this post! I encourage you to check that out here . The essay below has modified to address some of his points. Emotion is my favorite CSS-in-JS library. It's easy to define style classes — both inline or in separate files. You can powerfully compose classes in powerful ways with the cx utility (the Emotion equivalent of…

Choosing a tech stack for my personal dev blog in 2020

Check out the HN roast discussion here ! 🤗 This article has been translated into Russian . I recently set out to build my personal website — the one you're reading now, as it happens! Surprisingly, it was harder than expected assemble a "tech stack" that met my criteria. My criteria are pretty straightforward; I would expect most React devs to have a similar list. Yet it was surprisingly hard to…

Designing the perfect Typescript schema validation library

Update 2023 — Many of the problems with other libraries have been solved since this post was originally published. There are a handful of wildly popular validation libraries in the Javascript ecosystem with thousands of stars on GitHub. When I started my quest to find the ideal schema declaration/validation library, I assumed the hardest part would be identifying the Most Great option from a sea…