How to Set Up a MERN Stack in 2 Minutes with Kubernetes

How to Set Up a MERN Stack in 2 Minutes with Kubernetes

Setting up a local MERN stack usually means configuring React, Express, MongoDB, Docker, routing, HTTPS, and hot reload before you can write any application code. In this guide, we’ll show how GetWebstack creates a complete MERN development environment on Kubernetes with a single command, so you can start building immediately.

We built a MERN template that skips that part.

👉 MERN template: https://github.com/GetWebstack-public/MERN-stack

Clone it, run one command, and the whole stack comes up.

Quickstart: Set up a MERN stack with one command

This is the only setup required to run the full stack locally.

1. Clone the repository
2. Run:
    
    # REQUIRED SETUP
    gws login
    gws config import gws.json
    gws secret set JWT_SECRET --service server

    # START STACK
    [gws up](https://getwebstack.com/docs/commands/up/)

3. Open the generated HTTPS URLs

The first three lines are a one-time setup. After that, gws up is the whole workflow.

It builds the React frontend, the Express/Node.js API, and MongoDB, then deploys everything to a local Kubernetes cluster. It sets up routing and HTTPS and starts syncing your code into running containers. The first run takes about two minutes. After that, it’s faster.

When it finishes, you have real HTTPS URLs for the frontend and the API, both live. No ports to remember and no certificates to set up.

What the MERN template includes

  • Real HTTPS, not http://localhost. Your dev environment behaves like production, so you catch issues before deployment.
  • Live code sync. Edit a file, and the change is reflected in the running container. No rebuilds and no restarts.
  • Full isolation. The whole stack runs in its own Kubernetes namespace. Nothing leaks into your machine.
  • Consistent environments. Every teammate or AI agent gets the same setup by cloning the repo and running one command.
  • Zero Kubernetes knowledge required. The Dockerfiles, manifests, routing and database config are generated for you. You never write or touch YAML.

Skip Docker, Kubernetes, and local infrastructure setup

To build the same setup manually, you would write Dockerfiles, Kubernetes Deployments and Services, configure MongoDB, install a gateway, create certificates, configure local DNS, and wire up file sync. This can easily take a full day even for experienced engineers, and then you have to maintain it.

By handGetWebstack
Config you writeDockerfiles, K8s manifests, certs, DNS, syncNone (auto-generated)
Kubernetes knowledgeRequiredNot required
First-time setupMost of a day~2 minutes
HTTPS + isolationManual setupIncluded

GetWebstack generates all of it and keeps it in the repo, so every clone gets the same environment.

One isolated environment per branch

Each environment is isolated, so you can run several in parallel, one per branch, without conflicts: gws up -w <branch>.

This is especially useful when working with AI coding agents.

An agent can only test what it can actually run. Give it a real environment with a live URL and it can call the API, inspect database state, and validate its own changes before opening a pull request. Without this, it is working blind against an environment it cannot observe.

Deploy the same MERN stack to staging and production

The environment you run locally is not disposable. The same configuration used on your machine can be deployed to a VPS or remote server.

This allows you to run the same MERN stack in staging or production with minimal changes while keeping full control over your infrastructure.

Today, the remote setup is still manual. We are working on making it a single command so moving from local development to shared staging to production is as simple as gws up.

Try the MERN template

Install the GWS CLI, clone the template repository, and run gws up: github.com/GetWebstack-public/MERN-stack.

In a few minutes, you’ll have a complete MERN development environment running locally with HTTPS, routing, MongoDB and live code sync.

If you are using PostgreSQL instead of MongoDB, we also have a PERN stack template (PostgreSQL, Express, React, Node.js) that works the same way.