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

saas-template-injector

v1.0.0

Published

Automatically inject complete SaaS functionality into existing Next.js projects with authentication, payments, database, and admin features

Downloads

9

Readme

saas-template-injector

🚀 Instantly transform any Next.js project into a production-ready SaaS application

npm version License: MIT

✨ Features

  • 🔐 Authentication: Complete auth system with NextAuth.js (Google, GitHub, Credentials)
  • 💳 Payments: Stripe integration with subscriptions and webhooks
  • 🗄️ Database: PostgreSQL + Prisma ORM with migrations
  • 👥 Admin Dashboard: User management, analytics, and monitoring
  • 🛡️ Route Protection: Middleware-based access control
  • 💰 Credit System: Optional credit-based billing
  • 📊 Analytics: Built-in analytics dashboard
  • 🎨 Styling: Tailwind CSS with shadcn/ui components
  • 📝 TypeScript: Full TypeScript support

🚀 Quick Start

# Install globally
npm install -g saas-template-injector

# Navigate to your Next.js project
cd my-nextjs-app

# Inject SaaS template (dry run first)
saas-inject subscription . --dry-run

# Apply the template
saas-inject subscription . --install

📦 Installation

Global Installation (Recommended)

npm install -g saas-template-injector

Local Installation

npm install saas-template-injector --save-dev

Using npx (No Installation)

npx saas-template-injector subscription ./my-app

🎯 Usage

Command Line Interface

saas-inject <template> [project-path] [options]

Arguments

  • template - Template name or path to custom JSON template
  • project-path - Path to Next.js project (default: current directory)

Options

  • -h, --help - Show help
  • -v, --version - Show version
  • -d, --dry-run - Preview changes without modifying files
  • --verbose - Show detailed output
  • -i, --install - Install dependencies after generation
  • -m, --migrate - Run database migrations
  • -f, --force - Force injection even if not Next.js
  • --conflict-strategy - How to handle conflicts (merge|overwrite|skip|abort)

Preset Templates

1. Subscription (Full SaaS)

saas-inject subscription ./my-app

Includes: Auth, Stripe subscriptions, admin panel, user dashboard

2. Basic (Starter)

saas-inject basic ./my-app

Includes: Auth, database, basic dashboard

3. Credits (Usage-based)

saas-inject credits ./my-app

Includes: Credit system, usage tracking, pay-per-use

4. Enterprise (Advanced)

saas-inject enterprise ./my-app

Includes: Multi-tenant, SSO, audit logs, advanced analytics

Custom Templates

Create your own template JSON:

{
  "metadata": {
    "name": "My Custom SaaS",
    "version": "1.0.0"
  },
  "configuration": {
    "plans": [
      {
        "name": "Starter",
        "price": 9,
        "features": ["Feature 1", "Feature 2"]
      }
    ],
    "integrations": {
      "stripe": true,
      "nextauth": true
    }
  }
}

Use it:

saas-inject ./my-template.json ./my-app

🏗️ What Gets Generated

your-nextjs-app/
├── app/
│   ├── (auth)/
│   │   ├── signin/page.tsx      # Sign in page
│   │   └── signup/page.tsx      # Sign up page
│   ├── (dashboard)/
│   │   ├── dashboard/page.tsx   # User dashboard
│   │   ├── billing/page.tsx     # Billing management
│   │   └── settings/page.tsx    # User settings
│   ├── admin/
│   │   ├── dashboard/page.tsx   # Admin dashboard
│   │   ├── users/page.tsx       # User management
│   │   └── analytics/page.tsx   # Analytics
│   └── api/
│       ├── auth/[...nextauth]/  # NextAuth endpoints
│       ├── webhooks/stripe/      # Stripe webhooks
│       └── subscriptions/        # Subscription API
├── components/
│   ├── auth/                    # Auth components
│   ├── subscription/             # Billing components
│   └── admin/                    # Admin components
├── lib/
│   ├── auth.ts                  # Auth configuration
│   ├── db.ts                    # Database client
│   └── stripe.ts                # Stripe client
├── prisma/
│   ├── schema.prisma            # Database schema
│   └── seed.ts                  # Seed data
├── middleware.ts                # Route protection
├── .env.example                 # Environment template
└── package.json                 # Updated dependencies

🔧 Programmatic API

const { injectSaaSTemplate, createTemplate } = require('saas-template-injector');

// Use preset template
await injectSaaSTemplate('subscription', './my-app', {
  dryRun: false,
  install: true
});

// Create custom template
const template = createTemplate({
  name: 'My SaaS',
  plans: [
    { name: 'Free', price: 0 },
    { name: 'Pro', price: 29 }
  ]
});

// Apply custom template
await injectSaaSTemplate(template, './my-app');

🛠️ Configuration

Environment Variables

After injection, configure your .env.local:

# Database
DATABASE_URL="postgresql://user:pass@localhost:5432/mydb"

# NextAuth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key"

# Stripe
STRIPE_PUBLISHABLE_KEY="pk_test_..."
STRIPE_SECRET_KEY="sk_test_..."
STRIPE_WEBHOOK_SECRET="whsec_..."

# OAuth (Optional)
GOOGLE_CLIENT_ID="..."
GOOGLE_CLIENT_SECRET="..."
GITHUB_CLIENT_ID="..."
GITHUB_CLIENT_SECRET="..."

Database Setup

# Generate Prisma client
npx prisma generate

# Run migrations
npx prisma db push

# Seed database (optional)
npx prisma db seed

Stripe Setup

  1. Create products in Stripe Dashboard
  2. Add webhook endpoint: https://yourapp.com/api/webhooks/stripe
  3. Configure webhook events:
    • customer.subscription.created
    • customer.subscription.updated
    • customer.subscription.deleted
    • invoice.payment_succeeded

📋 Examples

Basic Injection

saas-inject subscription ./my-app

Dry Run First

saas-inject subscription ./my-app --dry-run

Full Setup

saas-inject subscription ./my-app --install --migrate

Force Overwrite

saas-inject subscription ./my-app --conflict-strategy=overwrite

Custom Template

saas-inject ./custom-saas.json ./my-app --verbose

🤝 Conflict Resolution

The tool intelligently handles existing files:

  • merge (default) - Merge with existing files
  • overwrite - Replace existing files
  • skip - Skip existing files
  • abort - Stop if conflicts found

🔍 Project Analysis

Before injection, the tool analyzes your project:

  • Detects Next.js version
  • Identifies existing routes
  • Checks for TypeScript/Tailwind
  • Finds potential conflicts
  • Validates project structure

🎨 Customization

Create Custom Templates

const { createTemplate } = require('saas-template-injector');

const myTemplate = createTemplate({
  name: 'My Custom SaaS',
  projectType: 'subscription',
  plans: [
    {
      name: 'Starter',
      price: 9,
      features: ['Feature 1', 'Feature 2']
    }
  ],
  integrations: {
    stripe: true,
    nextauth: true,
    analytics: true
  }
});

// Save as JSON
fs.writeFileSync('my-template.json', JSON.stringify(myTemplate, null, 2));

🚨 Important Notes

  • Backup your project before running
  • Use --dry-run to preview changes
  • Review generated files
  • Update environment variables
  • Test thoroughly after injection

📝 License

MIT

🤝 Contributing

Contributions welcome! Please read our Contributing Guide.

🐛 Bug Reports

Found a bug? Open an issue

📚 Documentation

Full documentation: https://docs.saas-injector.com

💖 Support

If this tool saved you time, consider:


Made with ❤️ for rapid SaaS development

Transform your Next.js app into a SaaS in minutes, not days!