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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mern-vite-shadcn-template

v3.0.1

Published

A MERN stack template with frontend and backend boilerplate.

Downloads

99

Readme

MERN Vite ShadCN Template

A boilerplate template for creating full-stack applications using the MERN (MongoDB, Express, React, Node.js) stack with Vite for the frontend, along with ShadCN for modern UI components. This template sets up both the frontend and backend, making it easier to start building applications with minimal setup.

Features

  • Backend:

    • Express.js server
    • MongoDB integration with Mongoose
    • JWT-based authentication (with jsonwebtoken)
    • Secure HTTP headers using Helmet
    • Cookie parsing and CORS handling
    • Modular folder structure for models, routes, controllers, services, and utilities
    • dotenv for environment configuration
  • Frontend:

    • React.js with Vite for fast development and build processes
    • ShadCN for pre-built UI components
    • TailwindCSS for styling
    • Modular structure for easy scaling
  • Development Tools:

    • Nodemon for automatic backend server restarts during development
    • Linting and basic configurations ready

Prerequisites

Make sure you have the following installed on your machine:

  • Node.js (v14.x or higher)
  • Git
  • MongoDB setup (either local or cloud)

Installation and Setup

1. Using the Package

To generate a new MERN project using this template, you can simply run the following command with npx:

npx mern-vite-shadcn-template@latest <your-project-name>

This command will:

  1. Clone the template repository.
  2. Set up the folder structure in the <your-project-name> directory.
  3. Install dependencies for both frontend and backend.

Example:

npx mern-vite-shadcn-template my-awesome-app

2. Project Structure

The generated project will have the following structure:

my-awesome-app/
├── backend/               # Backend API and logic
│   ├── config/            # Database configurations, constants
│   ├── controllers/       # Controllers for handling requests
│   ├── middlewares/       # Custom middlewares (e.g., authentication)
│   ├── models/            # MongoDB models using Mongoose
│   ├── routes/            # API routes
│   ├── services/          # Business logic or reusable functionalities
│   ├── utils/             # Utility functions
│   └── server.js          # Main Express server file
├── frontend/              # Vite-based React application
│   ├── src/               # Main source code for React app
│   ├── index.html         # Entry point for Vite
│   └── vite.config.js     # Vite configuration
├── .env                   # Environment variables (backend)
├── .gitignore             # Git ignore file
├── README.md              # Project documentation
├── package.json           # Root package file
└── package-lock.json      # Lock file for npm dependencies

3. Running the Project

After creating your project and navigating to the project folder, follow these steps to start the backend and frontend:

  1. Install dependencies:

    The command already installs all dependencies, but if needed, you can install manually by running:

    cd <your-project-name>
    npm install --prefix frontend && npm install
  2. Starting the development servers:

    • Backend (Runs on http://localhost:5000):

      npm run dev
    • Frontend (Runs on http://localhost:3000):

      cd frontend
      npm run dev
  3. Building the frontend for production:

    To build the frontend React app for production:

    cd frontend
    npm run build

Environment Variables

You’ll need to configure the environment variables in a .env file for the backend. An example .env.sample file is included.

Sample .env File

PORT=5000
MONGO_URI=""
NODE_ENV=development
JWT_SECRET=your_jwt_secret

CLOUDINARY_NAME=your_cloudinary_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret

Scripts

Here are some useful npm scripts for managing the project:

  • npm run dev: Starts the backend server in development mode using nodemon.
  • npm run build: Installs all necessary dependencies and builds the frontend for production.

Issues and Contributions

Feel free to open an issue if you run into problems or have suggestions for improvement. Contributions are welcome!


License

This project is licensed under the ISC License.


Acknowledgements

Special thanks to the authors and contributors of the libraries used in this template:


Happy Coding!