Building a Type-Safe Full-Stack Starter with Fastify and Astro
Latest Update
Following the deprecation of Lucia, I migrated session management to the recommended approach at lucia-next.pages.dev. This update also includes general fixes and improvements, such as resolving dark mode screen flashes.
Why This Stack?
As a solo developer, I often build JavaScript applications with separated server and client builds. While this is a valid approach, managing state across both can be complex.
I missed the simplicity of server-generated content enriching the client. Meta-frameworks like Next.js, Remix, Nuxt, and Astro handle this with SSR, but I wanted a solution that combined Astro’s frontend capabilities with a robust backend like Fastify.
The Two Integration Attempts
I explored two integration approaches:
-
Astro Adapter for Fastify: I found a repository with contributions from both Astro and Fastify maintainers. However, it didn’t work out of the box. Although I forked it and fixed dev mode, production mode remained problematic.
-
Node Middleware: Astro’s documentation provides middleware instructions for Node adapters. While this offers a clean separation, the example server wasn’t in TypeScript. Since I planned to use tRPC and Drizzle, a non-TypeScript backend was a dealbreaker.
Ultimately, I realized I could update my npm scripts to use tsx for watching and rollup for building. This flexible configuration aligns with Vite’s tooling and the recommended Astro setup.
What’s Included
This starter combines Astro, Fastify, tRPC, Lucia, React, NextUI, and Drizzle. It features:
- Full TypeScript support for end-to-end type safety.
- Session-based authentication via Lucia.
- Pre-configured login and registration flows.
Check out the Github Repo and let me know your thoughts.
Welcome to the Atomic Drafting Room
Why I tore down the Renaissance Technical design and rebuilt the site in Raygun Gothic — atomic starbursts, chrome typography, and a turquoise-coral-gold palette that finally feels like me.
Bringing AI to IBM i: An MCP Server with 31 System Tools
A BYOK MCP server that exposes 31 facade tools for IBM i observability, job management, and security. Built to train new users and accelerate expert workflows.
Renaissance Technical: Designing with AI
How I used OpenCode and Gemini to build a "Renaissance Technical" design system that pits rigid grids against organic circles—and why AI is the brush, not the painter.