authfyio-nuxt
Nuxt 3 integration — a server event handler that populates event.context.authfyio on every request. Pair with authfyio-vue on the client for composables + auto-refresh.
Copy this quickstart guide as a prompt for LLMs to implement Authfyio in your application.
Install
npm install authfyio-nuxt authfyio-vue authfyio-backendServer middleware
server/middleware/authfyio.ts
import { defineEventHandler } from 'h3';
import { authfyioEventHandler } from 'authfyio-nuxt';
export default defineEventHandler(
authfyioEventHandler({
// baseUrl defaults to https://api.authfyio.com
issuer: process.env.AF_JWT_ISSUER,
}),
);Your server routes now have event.context.authfyio — either the decoded session (userId, orgId, claims) or null.
Use it in a route
server/api/me.get.ts
import { defineEventHandler, createError } from 'h3';
export default defineEventHandler(async (event) => {
const auth = event.context.authfyio;
if (!auth) throw createError({ statusCode: 401 });
return { userId: auth.userId, orgId: auth.orgId };
});Client composables
Call provideAuthfyio once from app.vue and use useAuth / useUser anywhere — see authfyio-vue.