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

@tenxyte/vue

v0.5.5

Published

Vue bindings for the Tenxyte SDK

Readme

@tenxyte/vue

Vue 3 bindings for the Tenxyte SDK. Provides reactive composables that automatically update when authentication state changes.

Installation

npm install @tenxyte/core @tenxyte/vue

Quick Start

1. Install the plugin

import { createApp } from 'vue';
import { TenxyteClient } from '@tenxyte/core';
import { tenxytePlugin } from '@tenxyte/vue';
import App from './App.vue';

const tx = new TenxyteClient({
    baseUrl: 'https://api.example.com',
    headers: { 'X-Access-Key': 'your-api-key' },
    // Enable if backend uses HttpOnly cookie refresh tokens
    // cookieMode: true,
});

const app = createApp(App);
app.use(tenxytePlugin, tx);
app.mount('#app');

2. Use composables in any component

<script setup lang="ts">
import { useAuth, useUser, useRbac, useOrganization } from '@tenxyte/vue';

const { isAuthenticated, loading, logout } = useAuth();
const { user } = useUser();
const { hasRole } = useRbac();
</script>

<template>
    <p v-if="loading">Loading...</p>

    <div v-else-if="isAuthenticated">
        <p>Welcome, {{ user?.email }}</p>
        <AdminPanel v-if="hasRole('admin')" />
        <button @click="logout">Logout</button>
    </div>

    <LoginPage v-else />
</template>

Composables

useAuth()

Reactive authentication state and actions.

const {
    isAuthenticated, // Readonly<Ref<boolean>> — true if access token is valid
    loading,         // Readonly<Ref<boolean>> — true while initial state loads
    accessToken,     // Readonly<Ref<string | null>> — raw JWT access token
    loginWithEmail,  // (data: { email, password, device_info?, totp_code? }) => Promise<void>
    loginWithPhone,  // (data: { phone_country_code, phone_number, password, device_info? }) => Promise<void>
    logout,          // () => Promise<void>
    register,        // (data) => Promise<void>
} = useAuth();

Example — Login form:

<script setup lang="ts">
import { ref } from 'vue';
import { useAuth } from '@tenxyte/vue';

const { isAuthenticated, loginWithEmail, logout, loading } = useAuth();
const email = ref('');
const password = ref('');

async function handleLogin() {
    await loginWithEmail({ email: email.value, password: password.value });
}
</script>

<template>
    <p v-if="loading">Loading...</p>
    <button v-else-if="isAuthenticated" @click="logout">Logout</button>
    <form v-else @submit.prevent="handleLogin">
        <input v-model="email" placeholder="Email" />
        <input v-model="password" type="password" placeholder="Password" />
        <button type="submit">Sign In</button>
    </form>
</template>

useUser()

Decoded JWT user and profile management.

const {
    user,          // Readonly<Ref<DecodedTenxyteToken | null>> — decoded JWT payload
    loading,       // Readonly<Ref<boolean>>
    getProfile,    // () => Promise<UserProfile> — fetch full profile from API
    updateProfile, // (data) => Promise<unknown>
} = useUser();

Example:

<script setup lang="ts">
import { useUser } from '@tenxyte/vue';
const { user, loading } = useUser();
</script>

<template>
    <span v-if="!loading && user">{{ user.email }}</span>
</template>

useOrganization()

Multi-tenant organization context (B2B).

const {
    activeOrg,          // Readonly<Ref<string | null>> — current org slug
    switchOrganization, // (slug: string) => void
    clearOrganization,  // () => void
} = useOrganization();

Example:

<script setup lang="ts">
import { useOrganization } from '@tenxyte/vue';
const { activeOrg, switchOrganization, clearOrganization } = useOrganization();
</script>

<template>
    <select
        :value="activeOrg ?? ''"
        @change="(e) => (e.target as HTMLSelectElement).value
            ? switchOrganization((e.target as HTMLSelectElement).value)
            : clearOrganization()"
    >
        <option value="">No organization</option>
        <option v-for="org in orgs" :key="org.slug" :value="org.slug">
            {{ org.name }}
        </option>
    </select>
</template>

useRbac()

Synchronous role and permission checks from the current JWT.

const {
    hasRole,       // (role: string) => boolean
    hasPermission, // (permission: string) => boolean
    hasAnyRole,    // (roles: string[]) => boolean
    hasAllRoles,   // (roles: string[]) => boolean
} = useRbac();

Example:

<script setup lang="ts">
import { useRbac } from '@tenxyte/vue';
const { hasRole } = useRbac();
</script>

<template>
    <AdminPanel v-if="hasRole('admin')" />
    <p v-else>Access denied</p>
</template>

How It Works

The tenxytePlugin provides the TenxyteClient instance via Vue's dependency injection (app.provide). Each composable calls useTenxyteClient() internally to retrieve the client, then subscribes to SDK events (token:stored, token:refreshed, session:expired) using onMounted/onUnmounted lifecycle hooks. Reactive state is exposed as readonly(ref(...)) so templates update automatically.

Peer Dependencies

| Package | Version | |---|---| | @tenxyte/core | ^0.10.0 | | vue | ^3.3.0 |

License

MIT — see LICENSE