DEV Community

Shivam Kumar
Shivam Kumar

Posted on

I Built an Artisan-Like CLI for Next.js (MongoDB + JWT + CRUD in Seconds)

πŸš€ I Built an Artisan-Like CLI for Next.js (With MongoDB + JWT)

If you’ve ever built a backend with Next.js, you know the pain…

Every time you start a new project, you end up doing the same things:

  • Setting up MongoDB connection
  • Writing authentication (JWT, hashing passwords)
  • Creating API routes
  • Structuring folders

Again… and again… and again.


πŸ€” The Problem

Next.js is amazing for full-stack apps, but it doesn’t give you a backend scaffold like Laravel.

In Laravel, you have:

php artisan make:model
php artisan make:controller
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ Everything is fast and structured.

But in Next.js?

πŸ‘‰ You start from scratch every time.


πŸ’‘ The Idea

I wanted Laravel Artisan-like speed in Next.js.

So I built:

🧰 poudwal

A CLI that scaffolds full backend systems for Next.js 14 App Router.


🎬 Demo

poudwal demo


⚑ What poudwal Can Do

With a few commands, you can:

  • πŸš€ Create a full Next.js project
  • πŸ” Add JWT authentication (login/register)
  • πŸ“¦ Setup MongoDB with Mongoose
  • πŸ”„ Generate complete CRUD APIs
  • 🧱 Get a clean scalable structure
  • 🟦 Use TypeScript support

πŸš€ Quick Start


Enter fullscreen mode Exit fullscreen mode

npx poudwal create my-app --ts
cd my-app
npm install
npm run dev

Enter fullscreen mode Exit fullscreen mode

πŸ§‘β€πŸ’» Real Example

Let’s say you’re building an ecommerce app:

npx poudwal create ecommerce-app --ts
cd ecommerce-app

# Generate APIs
npx poudwal make:crud product
npx poudwal make:crud order

# Add authentication
npx poudwal install:auth
Enter fullscreen mode Exit fullscreen mode

πŸŽ‰ Done.

You now have:

  • Product & Order APIs
  • Authentication system
  • MongoDB setup
  • Ready backend

🧠 Why This Is Useful

Without poudwal:

  • ❌ Write models manually
  • ❌ Setup auth from scratch
  • ❌ Create API routes manually

With poudwal:

  • βœ… Everything generated instantly
  • βœ… Clean structure
  • βœ… Focus on business logic

βš™οΈ Key Commands

Create Project

poudwal create my-app
Enter fullscreen mode Exit fullscreen mode

Generate Model

poudwal make:model User
Enter fullscreen mode Exit fullscreen mode

Generate API

poudwal make:api product
Enter fullscreen mode Exit fullscreen mode

Generate Full CRUD

poudwal make:crud Product
Enter fullscreen mode Exit fullscreen mode

Install Auth

poudwal install:auth
Enter fullscreen mode Exit fullscreen mode

πŸ” Authentication Flow

  • User registers β†’ password hashed
  • User logs in β†’ JWT token generated
  • Middleware protects /api/* routes

🌱 Environment Setup

MONGODB_URI=mongodb://localhost:27017/myapp
JWT_SECRET=your_secret_key
JWT_EXPIRES=7d
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ Try It Yourself

πŸ‘‰ https://www.npmjs.com/package/poudwal


πŸ’¬ I’d Love Your Feedback

This is just the beginning.

If you’re a Next.js developer:

πŸ‘‰ Would this save your time?
πŸ‘‰ What feature should I add next?


πŸš€ Future Plans

  • Prisma support
  • Role-based authentication
  • Validation (Zod/Yup)
  • Better CLI UX

⭐ If You Like It

  • Star the repo
  • Try it in your next project
  • Share feedback

Thanks for reading πŸ™Œ

Top comments (0)