1.0.1 • Published 4 months ago

@devsuite/create-mern v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

create-mern

A powerful scaffolder for MERN stack projects with Vite + React frontend and Express + MongoDB backend.

Features

  • šŸš€ Fast Setup - Create full MERN stack projects in seconds
  • ⚔ Vite + React - Modern frontend development with hot reload
  • šŸ› ļø Express + MongoDB - Robust backend with Mongoose ODM
  • šŸ“¦ Package Manager Choice - Support for npm and pnpm
  • šŸ—ļø Flexible Structure - Choose full stack, frontend only, or backend only
  • šŸ”§ Pre-configured - CORS, environment variables, and development scripts included

Usage

npm create mern

or,

pnpm create mern

Follow the interactive prompts to: 1. Enter your project name 2. Choose project structure (Full MERN, Frontend only, or Backend only) 3. Select package manager (npm or pnpm)

Project Structure Options

1. Full MERN Stack

Creates a complete MERN application with separate frontend and backend directories:

my-project/
ā”œā”€ā”€ frontend/          # React + Vite application
ā”œā”€ā”€ backend/           # Express + MongoDB API
ā”œā”€ā”€ package.json       # Root package.json with scripts
└── README.md          # Project documentation

2. Frontend Only

Creates a React + Vite application:

my-project/
ā”œā”€ā”€ src/               # React components
ā”œā”€ā”€ public/            # Static assets
ā”œā”€ā”€ package.json       # Frontend dependencies
└── vite.config.js     # Vite configuration

3. Backend Only

Creates an Express + MongoDB API:

my-project/
ā”œā”€ā”€ routes/            # API routes
ā”œā”€ā”€ models/            # Mongoose models
ā”œā”€ā”€ controllers/       # Route controllers
ā”œā”€ā”€ config/            # Configuration files
ā”œā”€ā”€ server.js          # Main server file
ā”œā”€ā”€ .env               # Environment variables
└── package.json       # Backend dependencies

Generated Project Features

Frontend (React + Vite)

  • ⚔ Vite for fast development and building
  • šŸ”„ React Router for navigation
  • šŸ“” Axios for HTTP requests
  • šŸŽØ Modern React setup with JSX

Backend (Express + MongoDB)

  • 🌐 Express.js server with CORS enabled
  • šŸ—„ļø MongoDB connection with Mongoose
  • šŸ” Environment variable configuration
  • šŸ”„ Nodemon for development hot reload
  • šŸ“ Pre-configured API endpoints:
    • GET /api/health - Health check
    • GET /api/welcome - Welcome message
    • GET /api/users - Sample users endpoint

Available Scripts (Full Stack)

# Install all dependencies
npm run install:dependencies

# Start frontend development server
npm run dev:frontend

# Start backend development server
npm run dev:backend

# Build for production
npm run build

Environment Variables

For backend projects, a .env file is created with:

PORT=5000
MONGODB_URI=mongodb://localhost:27017/your-project-name
NODE_ENV=development

Requirements

  • Node.js >= 16.0.0
  • MongoDB/Atlas (for backend/full stack projects)

Package Managers

Supports both npm and pnpm package managers. Choose your preferred one during project creation.

Development

To contribute to create-mern:

git clone https://github.com/kmdtaufik/create-mern.git
cd create-mern
npm install

License

MIT

Keywords

  • MERN stack
  • React
  • Express
  • MongoDB
  • Vite
  • Scaffolder
  • Template
  • Full-stack development
1.0.1

4 months ago