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

@api-buddy/plugin-auth-firebase

v4.0.0

Published

CLI plugin for generating Firebase Authentication code in API Buddy projects

Readme

Firebase Auth Plugin for API Buddy

A comprehensive authentication solution for Next.js applications using Firebase Authentication. This plugin provides everything you need to add secure authentication to your API Buddy projects with minimal configuration.

✨ Features

  • Seamless Integration: Built specifically for the API Buddy ecosystem
  • Full-Stack Ready: Includes both frontend components and API routes
  • TypeScript First: Fully typed for a great developer experience
  • Production Ready: Battle-tested patterns for security and reliability
  • Customizable: Easy to extend and style to match your application

🚀 Quick Start

  1. Create a new Next.js application (if you haven't already):

    npx create-next-app@latest my-app
    cd my-app
  2. Install the plugin:

    pnpm add @api-buddy/plugin-auth-firebase
  3. Initialize Firebase Auth:

    npx api-buddy firebase-auth init --project-id your-project-id --api-key your-api-key --auth-domain your-app.firebaseapp.com

    This will:

    • Set up Firebase configuration
    • Create necessary API routes
    • Generate authentication pages
    • Configure environment variables

🔧 Initialization

The init command sets up everything needed for Firebase Authentication:

npx api-buddy firebase-auth init [project-dir] [options]

Options:

| Option | Description | Default | |--------|-------------|---------| | -f, --force | Overwrite existing files | false | | --skip-install | Skip installing dependencies | false | | --only-api | Only generate API routes | false | | --only-pages | Only generate pages | false | | --only-components | Only generate components | false | | --dry-run | Run without making changes | false | | --project-id <projectId> | Firebase project ID | - | | --api-key <apiKey> | Firebase API key | - | | --auth-domain <authDomain> | Firebase auth domain | - | | --use-emulator | Use Firebase emulator | false | | --emulator-host <host> | Firebase emulator host | localhost | | --emulator-port <port> | Firebase emulator port | 9099 | | --auth-providers <providers> | Comma-separated list of auth providers | email | | --no-email-verification | Disable email verification | true | | --no-password-reset | Disable password reset | true |

Examples:

  1. Basic setup with email authentication:

    npx api-buddy firebase-auth init --project-id my-project --api-key abc123 --auth-domain my-app.firebaseapp.com
  2. Setup with Google and GitHub auth:

    npx api-buddy firebase-auth init --project-id my-project --auth-providers "email,google,github"
  3. Setup with emulator:

    npx api-buddy firebase-auth init --use-emulator --emulator-port 9099

What it does:

  1. Configuration

    • Creates a Firebase configuration file
    • Sets up environment variables
    • Configures Firebase Admin SDK
    • Sets up authentication providers
    • Configures email verification and password reset
  2. API Routes

    • /api/auth/signin - Handle user sign in
    • /api/auth/signup - Handle user registration
    • /api/auth/signout - Handle user sign out
    • /api/auth/session - Get current session
  3. Frontend

    • Authentication provider
    • Custom hooks
    • Example pages

⚛️ Using Frontend Hooks

The plugin provides several React hooks for authentication:

useAuth Hook

'use client';

import { useAuth } from '@api-buddy/plugin-auth-firebase';

export default function Profile() {
  const {
    user,           // Current user object or null
    loading,        // Loading state
    error,         // Error object if any
    signIn,        // Sign in function
    signUp,        // Sign up function
    signOut,       // Sign out function
    updateProfile, // Update user profile
  } = useAuth();

  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return (
    <div>
      {user ? (
        <div>
          <h1>Welcome, {user.displayName || user.email}!</h1>
          <button onClick={signOut}>Sign Out</button>
        </div>
      ) : (
        <div>
          <button onClick={() => signIn({ email: '[email protected]', password: 'password' })}>
            Sign In
          </button>
        </div>
      )}
    </div>
  );
}

useUser Hook

For simple user access:

'use client';

import { useUser } from '@api-buddy/plugin-auth-firebase';

export default function UserInfo() {
  const user = useUser();
  
  if (!user) return <div>Not signed in</div>;
  
  return (
    <div>
      <p>Email: {user.email}</p>
      <p>Name: {user.displayName || 'Not set'}</p>
    </div>
  );
}

🔄 API Buddy Ecosystem Integration

This plugin is designed to work seamlessly with the API Buddy ecosystem:

  1. Unified Authentication

    • Single sign-on across all API Buddy services
    • Centralized user management
    • Consistent authentication patterns
  2. API Protection

    • Automatic token validation
    • Role-based access control
    • Rate limiting and security headers
  3. Development Experience

    • TypeScript support
    • Hot reloading
    • Development tools

🔒 Environment Variables

After initialization, you'll need to set these environment variables in your .env.local. Instructions for obtaining the api keys from Firebase are in /docs/FIREBASE-SETUP.md.

📚 Documentation

For more detailed information, please refer to:

🤝 Contributing

Contributions are welcome! Please read our Contributing Guide to get started.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.