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

@snowfoxlab/mock-login-api

v1.0.2

Published

A simple mock login helper for frontend developers — generate fake tokens, roles, and user data for testing.

Readme

mock-login-api

A simple mock login helper for frontend developers. Generate fake JWT tokens, user roles, usernames, and emails for testing your frontend auth flow — no backend required.

Perfect for React, Next.js, Expo, or any modern web app.

Live Demo

Try the demo page here:
https://snowfoxlab.github.io/mock-login-api/test.html


Installation

npm install @snowfoxlab/mock-login-api

Local Development

# Clone this repo
git clone https://github.com/snowfoxlab/mock-login-api.git
cd mock-login-api
npm install

# Link to your project
npm link
cd /path/to/your-project
npm link mock-login-api

Quick Start

import { login, getUser, logout, getToken, clear } from "mock-login-api";

// Log in a mock user
const user = login({
  username: "boss",
  role: "admin",
  email: "[email protected]",
});

console.log("✅ Logged in:", user);
// Output: { token: 'mock-abc123.1680204512345', username: 'boss', role: 'admin', email: '[email protected]' }

// Get current user
console.log("👤 Current user:", getUser());

// Get current token only
console.log("🔑 Token:", getToken());

// Clear all stored user data
clear();

// Logout
logout();
console.log("🔒 After logout:", getUser()); // null

API Reference

| Function | Description | Returns | | ---------------------------------- | -------------------------- | ---------------------------------- | | login({ username, role, email }) | Log in a mock user | { token, username, role, email } | | getToken() | Get current mock JWT token | Token string or null | |getUser() | Get the current mock user | User object ornull | |logout() | Clear the mock user data |void | |clear() | Clear all storage |logout ` |

React Example

import React, { useState } from "react";
import { login, getUser, logout } from "mock-login-api";

export default function App() {
  const [user, setUser] = useState(getUser());

  const handleLogin = () => {
    const loggedInUser = login({
      username: "admin",
      role: "administrator",
      email: "[email protected]",
    });
    setUser(loggedInUser);
  };

  const handleLogout = () => {
    logout();
    setUser(null);
  };

  return (
    <div>
      <h1>Mock Login Demo</h1>

      {user ? (
        <div>
          <h2>Welcome, {user.username}!</h2>
          <p>Role: {user.role}</p>
          <p>Email: {user.email}</p>
          <p>Token: {user.token}</p>
          <button onClick={handleLogout}>Logout</button>
        </div>
      ) : (
        <div>
          <p>Not logged in</p>
          <button onClick={handleLogin}>Login as Admin</button>
        </div>
      )}
    </div>
  );
}

Use Cases

  • Frontend Development: Test auth flows without a backend
  • Component Testing: Mock user states in Storybook or Jest
  • Demos & Prototypes: Show auth functionality quickly
  • CI/CD Testing: Safe mock data for automated tests

Features

  • Zero Setup — Works immediately after install
  • 🔒 Safe — No real authentication, perfect for demos
  • 🪶 Lightweight — Zero dependencies
  • 🧩 Framework Agnostic — Works with any JavaScript framework
  • 🎯 TypeScript Ready — Full type support included
  • New — Clear function & date-based token generation
  • ❄️ New — Live demo page with snowfall effect and UI

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

For major changes, please open an issue first to discuss what you would like to change.

License

MIT © Snowfoxlab

Contributors

Bikash Adhikari

GitHub
LinkedIn

Lead Developer & Maintainer of this project. Passionate about open-source and building developer tools.


Snowfoxlab Team

GitHub

Organization supporting this project and its ecosystem.