Full-stack notes
Practical write-ups on the MERN stack by Muhammad Osama Khan, Software Engineer in Karachi, Pakistan: authentication, MongoDB, Express APIs, React data fetching and shipping to production.
Articles
Deploying a MERN App: Environment Variables, CORS and a Production Checklist
DevOps, Nov 7, 2026, 4 min read. The settings that differ between your laptop and production: secrets, CORS, cookies behind a proxy, rate limits, health checks and graceful shutdown.
Server State in React with RTK Query: Caching, Invalidation and Optimistic Updates
React, Nov 3, 2026, 4 min read. Stop hand-writing loading flags and refetch logic. Define endpoints once, tag the data and let RTK Query keep the cache correct.
Fixing Slow MongoDB Queries: Indexes, explain() and Cursor Pagination
Performance, Oct 27, 2026, 3 min read. Read explain() output, build the right compound index and replace skip-based pagination with a cursor. Steps you can repeat on any slow endpoint.
How to Structure an Express API: Routes, Controllers, Services and Error Handling
APIs, Oct 20, 2026, 4 min read. Keep routes thin, put business rules in services, validate input at the edge and handle every error in one place.
MongoDB Schema Design for MERN Apps: Embed or Reference?
Database, Oct 13, 2026, 3 min read. Embed what you always read together and what stays small; reference what grows or is shared. Worked examples with Mongoose models.
JWT Authentication in a MERN App: Access Tokens, Refresh Tokens and httpOnly Cookies
Auth, Oct 6, 2026, 4 min read. Keep the access token in memory, the refresh token in an httpOnly cookie, and retry once on a 401. A complete flow with Express and React code.
Next.js Server Components vs Client Components: What Runs Where and When to Use Each
Next.js, Sep 29, 2026, 4 min read. Components are server components by default. Learn what that changes, how to keep the client boundary small and the errors to watch for.
Prisma with PostgreSQL: Schema Design, Migrations and Avoiding N+1 Queries
Database, Sep 22, 2026, 4 min read. Model relations, ship migrations without surprises, replace query loops with include and wrap multi-step writes in a transaction.
Testing React Components with Vitest and React Testing Library
Testing, Sep 15, 2026, 3 min read. A working Vitest setup, tests that query the page like a user does, a mocked API call and the habits that keep tests from breaking on every refactor.
A GitHub Actions CI/CD Pipeline for a Vite and Node.js App
DevOps, Sep 8, 2026, 3 min read. One workflow that checks every push and pull request, and a second job that deploys to production only when those checks are green.
Real-Time Features with Socket.IO and React: Rooms, Auth and Clean-Up
Real-time, Sep 1, 2026, 4 min read. A chat-style example: a Socket.IO server with JWT auth and rooms, and a React hook that connects, joins, listens and cleans up properly.
Zustand or Redux Toolkit? Choosing State Management for a React App
React, Aug 25, 2026, 3 min read. The same cart written with Zustand and with Redux Toolkit, a plain comparison, and a simple way to decide which one your app needs.