Skip to content

Nuxt / H3

Import from @system-core/core/integrations/nuxt.

Use this adapter for Nuxt 3 and Nitro request handling. It is the default choice when the host runtime is H3-based.

Use Cases

  • Nuxt 3 server routes and API handlers calling package-owned CMS or auth flows
  • Nitro middleware wrapping system-core rate limiting or session validation
  • Any H3-compatible server handler that needs to pass an event to system-core logic

How It Works

The adapter implements HttpAdapter against H3's H3Event. It delegates each method directly to the matching H3 utility (getHeader, getCookie, readBody, etc.) so there is no abstraction overhead — the H3 event is passed straight through.

text
H3Event → h3Adapter → HttpAdapter → system-core logic functions

Basic Setup

Install

bash
npm install @system-core/core zod @prisma/client h3
npm install bcryptjs jsonwebtoken nodemailer

Create a handler

ts
// server/api/pages/index.get.ts
import { defineHandler } from '@system-core/core/integrations/nuxt'
import { system } from '~/server/system'

export default defineHandler(async (event, http) => {
  return system.cms.listPublishedPages()
})

defineHandler wraps your function in defineEventHandler and passes both the raw H3Event and the pre-bound h3Adapter as http.

Create middleware

ts
// server/middleware/session.ts
import { defineMiddleware } from '@system-core/core/integrations/nuxt'
import { system } from '~/server/system'

export default defineMiddleware(async (event, http) => {
  const token = http.getHeader(event, 'authorization')?.replace('Bearer ', '') ?? ''
  if (!token) return
  const session = await system.auth.sessions.verifyToken?.(token)
  if (session) event.context.user = session
})

Use the adapter directly

ts
import { h3Adapter } from '@system-core/core/integrations/nuxt'
import type { H3Event } from 'h3'

export async function readPageSlug(event: H3Event): Promise<string> {
  const query = h3Adapter.getQuery(event)
  return String(query.slug ?? '')
}

API Reference

ExportKindDescription
h3Adapter / httpAdapterHttpAdapterThe H3 adapter instance
defineHandler(fn)functionWraps a handler into defineEventHandler
defineMiddleware(fn)functionWraps middleware into defineEventHandler

system-core documentation for maintainers, integrators, and AI build agents.