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

@alwatr/nitrobase-user-management

v7.10.1

Published

User management module for Nitrobase, providing user creation, authentication, and data management capabilities.

Downloads

915

Readme

Nitrobase User Management

User management module for Nitrobase, providing user creation, authentication, and data management capabilities.

Installation

npm install @alwatr/nitrobase

Usage

import {AlwatrNitrobase, NitrobaseUserManagement, type NewUser} from '@alwatr/nitrobase';

// Define your user data structure
interface MyUserData {
  name: string;
  email: string;
  // ... other properties
}

// Initialize Nitrobase
const nitrobase = new AlwatrNitrobase({
  // ... your nitrobase configuration
});

// Initialize User Management
await NitrobaseUserManagement.initialize(nitrobase);

const userManagement = new NitrobaseUserManagement<MyUserData>(nitrobase);

// Create a new user
const newUser: NewUser<MyUserData> = {
  userId: 'user123',
  userToken: 'some_secure_token',
  data: {
    name: 'John Doe',
    email: '[email protected]',
  },
};

await userManagement.newUser(newUser);

// Check if a user exists
const userExists = await userManagement.hasUser('user123');
console.log('User exists:', userExists); // Output: User exists: true

// Get user data
const userData = await userManagement.getUserData('user123');
console.log('User data:', userData); // Output: User data: { name: 'John Doe', email: '[email protected]' }

// Verify user token
const isValidToken = await userManagement.verifyUserToken('user123', 'some_secure_token');
console.log('Is valid token:', isValidToken); // Output: Is valid token: true

// Save user data (after modifications)
userData.email = '[email protected]'
userManagement.save('user123') // Background save
userManagement.saveImmediate('user123') // Immediate save (blocking)


// Get all user IDs
const userIds = await userManagement.userIds();
for await (const userId of userIds) {
  console.log('User ID:', userId);
}

// Get user directory
const userDir = await userManagement.getUserDirectory('user123');
console.log('User directory:', userDir);

API

NitrobaseUserManagement

  • static initialize(nitrobase: AlwatrNitrobase): Promise<void>: Initializes the user management module. Must be called before creating a NitrobaseUserManagement instance.
  • newUser(user: NewUser<TUser>): Promise<void>: Creates a new user with the provided data and token. Sets up necessary storage and metadata.
  • hasUser(userId: string): Promise<boolean>: Checks if a user with the given ID exists.
  • getUserData(userId: string): Promise<TUser>: Retrieves the data associated with the given user ID.
  • getUserMeta(userId: string): Promise<Readonly<StoreFileMeta>>: Retrieves metadata about the user's stored information.
  • verifyUserToken(userId: string, token: string): Promise<boolean>: Verifies the provided token against the stored token for the user.
  • save(userId: string): void: Saves any changes to the user's data. This operation is non-blocking.
  • saveImmediate(userId: string): void: Immediately saves changes to the user's data. This operation is blocking.
  • userIds(): Promise<Generator<string, void, void>>: Returns an asynchronous generator that yields all user IDs.
  • getUserDirectory(userId: string): Promise<string>: Retrieves the file system directory associated with the user.

Types

  • NewUser<TUser extends JsonObject>: Represents the data required to create a new user. Includes user ID, token, and user-specific data.

Contributing

Contributions are welcome! Please read our contribution guidelines before submitting a pull request.