Building a Nuxt Module: Going Further
Based on the official Nuxt release notesPicking up from The Basics, where nuxt-presence got a component, a composable and a client plugin — a wall that works until you refresh.
Three steps to make it a module you'd let someone else install. Server routes that don't exist unless they're asked for. Options that are typed, deep-merged, and split by who's allowed to read them. Tests at the cheapest tier that can actually prove each thing.
This series continues the same package. If you haven't done The Basics, start there — every step here builds on that code.
What we cover here#
- Server Persistence & TTL —
addServerHandler, Nitro routes, and a store that forgets. - A Real Options Surface —
ModuleOptions, deep-merged defaults, declaration merging, and the public/private runtime config decision. - Testing the Module —
@nuxt/test-utils, and a rule for which tier a behaviour belongs in.
Three of the four bugs this module actually shipped and had to fix live in these steps. They're boxed as warnings where you'd otherwise write the broken version yourself.
Where it goes next#
- Nuxt Modules Capstone: The Signed Build — Advanced. ed25519 keys, build-time signing, a verify endpoint that can't be tricked, and the deploy.
How this series works#
Each step follows the same path: What it is → Why you'd care → Before → After → Do it yourself → Gotchas → Recap.