npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@better-iam/vue

v0.2.0

Published

Vue 3 bindings for Better IAM: a plugin, composables for the session and authorization decisions, and an IamCan component, with SSR support.

Downloads

384

Readme

@better-iam/vue

Vue 3.3+ bindings for the Better IAM browser client: a plugin holding one session store, composables for the session and advisory authorization decisions, and an IamCan component, with server-rendering support. Everything here is advisory UI state; the server enforces every operation. Nuxt apps use @better-iam/nuxt, which installs this for you.

import { createApp } from 'vue';
import { createIamClient } from '@better-iam/client';
import { createIam } from '@better-iam/vue';
import type { iam } from './server.js';

const client = createIamClient<typeof iam>({ baseURL: 'https://app.example.com' });
createApp(App).use(createIam({ client })).mount('#app');
<script setup lang="ts">
import { useAccessible, useAuthorize, useSession, IamCan } from '@better-iam/vue';
const props = defineProps<{ tenantId: string; projectId: string }>();
const { status, session, signOut } = useSession<typeof client>();
const { allowed } = useAuthorize(() => ({
  tenantId: props.tenantId,
  checks: [{ action: 'projects:manage', resource: { type: 'project', id: props.projectId } }],
}));
const { resources } = useAccessible(() => ({
  tenantId: props.tenantId,
  action: 'projects:read',
  type: 'project',
}));
</script>

<template>
  <p v-if="status === 'loading'">Loading…</p>
  <template v-else-if="session">
    {{ session.identity.name }} <button @click="signOut">Sign out</button>
    <button v-if="allowed('projects:manage', { type: 'project', id: projectId })">Manage</button>
    <IamCan :tenant-id="tenantId" action="iam:identities:create">
      <a href="/invite">Invite a member</a>
      <template #fallback>Ask an administrator to invite people.</template>
    </IamCan>
  </template>
</template>
  • createIam({ client, initialSession?, refreshOnFocus?, refreshIntervalMs?, hydration?, server? }) loads the session on install unless initialSession is given (null = known signed-out), refreshes on focus by default, and registers IamCan globally (registerComponents: false to skip).
  • useSession returns computed status, session, error, isAuthenticated plus refresh, signOut, and setSession for applying a sign-in response.
  • useAuthorize, useCan, and useAccessible take a ref or getter and re-run when it changes or the signed-in identity changes. A session refresh for the same identity does not re-run them.
  • useAgreements({ tenantId }) returns the person's terms of use, pending (required, not accepted in their current version), and accept(agreement); useAccessPaths({ tenantId, action, resource }) returns allowed and, when denied, the self-service paths (mfa, accept-agreements, activate, request-package) the server verified would allow the person. Both are prefetched during SSR like the others.
  • useTeams({ tenantId }) returns the person's teams (role, expiry, and the teams above each), their pending join requests, and the teams they may ask to join (joinable), with requestToJoin(teamId, justification?), cancelRequest(requestId), and leave(teamId). See teams and departments.
  • Server rendering: with server: true (detected when window is absent), queries in rendered components are awaited through onServerPrefetch and written to hydration. On the client, each hydrated result is used once instead of fetching, so markup matches. createHydration(state?) is a plain-object implementation to serialize.
  • createSessionStore / isUnauthenticated come from @better-iam/client/session, shared with @better-iam/react.

License: Apache-2.0.