🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101

Blog platform with login (MERN)

Users sign up, write posts with images, comment and like; a complete MERN app with authentication.

Intermediate⏱ 16–24 hoursđŸĒœ 7 stepsMongoDBExpressReactNode.js

What you'll learn

  • ◆REST API design with Express
  • ◆MongoDB models with Mongoose
  • ◆Auth with hashed passwords and httpOnly cookies

What you'll build

  • ✓Sign up / log in / log out
  • ✓Create, edit, delete your posts
  • ✓Comments and likes
  • ✓Search and pagination

Step-by-step guide

  1. 1

    Backend setup

    npm init; npm i express mongoose bcrypt jsonwebtoken cookie-parser cors dotenv; connect with mongoose.connect(process.env.MONGO_URL).

  2. 2

    Models

    User {name, email unique, passwordHash}, Post {title, body, author ref, likes [ref], createdAt}, Comment {post, author, text}.

  3. 3

    Auth

    Hash with bcrypt; on login sign a JWT and send it in an httpOnly, secure, sameSite cookie; middleware verifies it and sets req.user.

  4. 4

    Post routes

    GET /api/posts?page=&q=, POST /api/posts (auth), PUT/DELETE /api/posts/:id (author only).

  5. 5

    Front end

    React with React Router: Home, Post, Editor, Login, Register; fetch with credentials: "include".

  6. 6

    Validation and errors

    Validate bodies (for example with zod), return 400/401/403/404 consistently and show them in the UI.

  7. 7

    Deploy

    MongoDB Atlas free tier for the database, the API and front end on a free hosting plan; keep secrets in environment variables.

🚀 Make it stand out

  • +Image upload to cloud storage
  • +Rich text editor
  • +Email verification