@better-iam/nuxt

Nuxt module for Better IAM: the IAM API in Nitro, server-rendered sessions, page guards with definePageMeta, and auto-imported composables.
609 6
Install
npm install @better-iam/nuxt
Latest Version:0.3.1
Vue:3
License:Apache-2.0
Last Updated:Oct 9, 2026
Links: GitHub  ·  npm
Maintainer: legionedge

@better-iam/nuxt

Better IAM for Nuxt 3.14+ and 4. The module mounts the IAM API in Nitro and renders the session on the server, where advisory decisions are also resolved and then hydrated. It guards pages with definePageMeta({ iam }) and auto-imports composables, <IamCan>, and server utilities. See the Nuxt guide.

// nuxt.config.ts: server/iam.ts exports the betterIam() instance as `iam`
export default defineNuxtConfig({
  modules: ['@better-iam/nuxt'],
  betterIam: { instance: '~~/server/iam', loginPath: '/login' },
});
<script setup lang="ts">
definePageMeta({ iam: { action: 'projects:manage' } }); // or `true` for any session, `false` to opt out
const { session } = useIamSession();
</script>

<template>
  <IamCan :tenant-id="session!.session.tenantId" action="iam:identities:create">
    <NuxtLink to="/invite">Invite</NuxtLink>
  </IamCan>
</template>
// server/api/me.get.ts
export default defineEventHandler(async (event) => {
  const { identity, session } = await requireIamSession(event);
  await requireIamAccess(event, { tenantId: session.tenantId, action: 'projects:read' });
  return identity;
});
  • App auto-imports: useIamSession, useIamClient, useIamAuthorize, useIamCan, useIamAccessible, and <IamCan>. Sessions are typed from the registered instance.
  • Server auto-imports: getIamSession, requireIamSession, requireIamAccess, iamCan, issueIamAssertion, iamCredential, and useIam.
  • @better-iam/nuxt/h3 exports createIamH3 for h3 v1/v2 and Nitro apps without the module.

License: Apache-2.0.

Related Packages

@better-iam/vue

Vue 3 bindings for Better IAM: a plugin, composables for the session and authori...

782 6
nuxt-token-authentication

Token Authentication for Nuxt Server APIs

541 5
nuxt-authorization

Authorization module for managing permissions on the Nuxt app and the Nitro serv...

188,002 360
vue-nuxt-permission

A unified permission system for Vue 3 and Nuxt 3 / Nuxt 4 with directives, guard...

2,570 0
@authup/client-web-nuxt

Nuxt module that signs your app in with Authup and guards its routes by login st...

11,785 41

Version History

Version Released Vue License
0.3.1 ^3.3.0 Apache-2.0
0.3.0 ^3.3.0 Apache-2.0
0.2.0 ^3.3.0 Apache-2.0
0.1.0 ^3.3.0 MIT