# Shipping to Production: From Your Laptop to Real Users by [kirupa](https://www.kirupa.com/me/index.htm) | filed under [Build Essentials](https://www.kirupa.com/build/index.htm) **TL;DR:** Getting code from our laptop to the people who use it means running it on a host that's always on, pointing a domain at it with DNS, keeping test and real settings in separate environments, and letting a pipeline test and deploy every change. That live copy is called production. - A file host is enough for pages that show everyone the same thing. Code that saves orders or charges cards needs an app host or serverless functions. - Development, staging, and production run the same code with different settings, like a test or live payment key. Most works-on-my-machine bugs come from differences between environments. - CI/CD runs install, test, build, and deploy on every push, and a failing test stops the deploy before customers ever see the bug. - Secrets like API keys belong in the host's and GitHub's secret settings, never in code. A leaked key has to be rotated, since Git's history keeps the old one. Wren has been building a page for ordering Crumb & Co.'s birthday cakes, and it's looking great. Customers pick a cake, choose a pickup day, and pay. There is just one problem. The page only exists on Wren's laptop, at an address that starts with `localhost`, and the bakery's owner wants to email the link to her newsletter subscribers on Friday morning. Getting code from our laptop to the people who will actually use it takes a handful of pieces: somewhere to run it, a name people can type, a safe way to ship changes, and a safe spot for our passwords and keys. In this article, we are going to set up all of that for our cake page, so that shipping the next change becomes the most boring part of the week. Onwards! ## Why Doesn't Our Link Work for Anyone Else? Right now, our page is served by a small web server that runs on Wren's laptop. When Wren opens `http://localhost:5173`, the browser asks that server for the page, and the server answers. The catch is that `localhost` always means *this computer*. When the owner types the same address on her phone, her phone asks itself for the page: ![On the left, Wren's laptop shows the birthday cake order page at localhost:5173. On the right, the owner's phone opens the same address and shows This site can't be reached, because localhost on her phone means her own phone.](https://www.kirupa.com/build/images/shipping_to_production_localhost.png) Her phone has no cake page on it, so she gets an error. Wren's laptop also goes to sleep, gets carried to coffee shops, and installs updates at the worst possible moment. For our page to work on Friday, it will need to run on a computer that is always on and reachable from anywhere. ## What Is Production? The copy of our app that real customers use has a name. It's called **production** (aka *prod*), and getting our code there is called **deploying** or **shipping to production**. The copy on Wren's laptop is only for building and trying things out. Between the two sits a path that our code will travel every time we change something. We'll walk through it one stop at a time, and the whole trip looks as follows: ![A conveyor belt carries code from left to right: Wren's laptop, then GitHub, then automatic checks, then a private staging copy, then production at crumbandco.com, and finally customers.](https://www.kirupa.com/build/images/shipping_to_production_conveyor.png) Our code starts on Wren's laptop and gets pushed to GitHub, where every version of it is kept ([Git and Version Control](https://www.kirupa.com/build/git_and_version_control.htm) covers how). Automatic checks test it, a private copy lets Wren try it out, and only then does it reach production. By the end of this article, this whole belt will run on its own every time Wren pushes a change. ## Where Does Our Site Live? The first thing we need is a computer that never sleeps. We could keep one in the bakery's back room next to the flour, but almost nobody does that anymore. Instead, we rent space on computers that someone else keeps running, and a company that rents out that space is called a **host**. Hosts come in a few flavors, depending on what our code needs to do: ![Three kinds of hosts. A file host sends the same files to everyone, which is good for a menu page. An app host keeps our server code running, which is good for taking orders, and it's where our cake page goes. Serverless functions wake up for each request, which is good for small jobs now and then.](https://www.kirupa.com/build/images/shipping_to_production_hosting_kinds.png) A page that shows the same menu to everyone only needs a file host, and [Deploying Your React App](https://www.kirupa.com/react/deploying_react_apps.htm) walks through four of them. Our cake page saves orders and charges cards, so it needs code running on a server, which means an app host like Render, Railway, or Fly.io. ([Deploying an Agent](https://www.kirupa.com/ai_fundamentals/deploying_an_agent.htm) compares hosts for code that runs for minutes at a time.) ## How Does a Name Find Our Server? Our host gives us an address like `crumb-cakes.onrender.com`. It works, but it isn't something the owner wants to print on a cake box. Wren buys `crumbandco.com` from a company that sells names (a **domain registrar**) and connects it to the host through a giant, shared lookup system. When a customer types our name, here is what happens: ![Three steps. 1: a customer's phone asks DNS, Where is crumbandco.com? 2: DNS answers with the address 203.0.113.10. 3: the phone connects to our host at that address over https, shown with a padlock.](https://www.kirupa.com/build/images/shipping_to_production_dns.png) That lookup system is called **DNS** (the Domain Name System), and it works a lot like the contacts app on our phones. We look up a name, and we get back a number. To get our name into it, Wren adds two records at the registrar: ![A registrar's DNS settings with two records. An A record points crumbandco.com at the address 203.0.113.10. A CNAME record points www at crumb-cakes.onrender.com, the address our host gave us.](https://www.kirupa.com/build/images/shipping_to_production_dns_record.png) These records say that `crumbandco.com` and `www.crumbandco.com` both lead to our host, so lookups for either name end up there. Most hosts also hand out a free certificate, which is what makes the address start with `https`. DNS changes can take a while to spread, since computers around the world remember old answers for a bit, so Wren hooks up the domain on Tuesday instead of Friday morning. ## Why Not Just Copy the Files Over? With a host and a name, Wren could copy the code onto the server by hand and call it a day. A trading firm called Knight Capital learned in 2012 why that is a risky habit. Knight was putting new code on eight servers by hand, and according to the [SEC's order](https://www.sec.gov/files/litigation/admin/2013/34-70694.pdf), a technician didn't copy the new code to one of them, and nobody else checked the work: ![Eight of Knight Capital's servers in a row. Servers 1 to 7 got the new code. Server 8 was missed and still had the old code. On August 1, 2012, Knight lost $460 million in about 45 minutes.](https://www.kirupa.com/build/images/shipping_to_production_knight.png) On August 1, that eighth server started running old code that nobody meant to run. In about 45 minutes, Knight lost **$460 million**. Our cake page is a lot smaller than a trading system, but the lesson scales down really well. When a person repeats the same steps by hand, one day a step gets skipped. Our deploys should happen exactly the same way every single time, which means a script will do them instead of our memory. ## Same Code, Different Settings Before we automate anything, there is one more idea we need. On Wren's laptop, our page should use test data and fake card payments. On the real site, it should use real orders and real payments. The code is the same everywhere, and only a few settings change: ![Three environments side by side. Development on Wren's laptop, staging, and production all run the same code, version 42. Development and staging use test data and a test payment key. Production uses real orders and the live payment key. Emails go to Wren in development, the team in staging, and customers in production.](https://www.kirupa.com/build/images/shipping_to_production_environments.png) Each of these copies is called an **environment**, and most teams have at least three. Development is where we build. **Staging** is a private copy of production where we try a change for real before customers see it. Production is the real thing. The settings that differ (which database, which payment key, who gets the emails) are called **configuration**. Our code never contains those values. It asks for each one by name, and each environment fills in its own answer: ![Our code asks for settings by name, like process.env.STRIPE_KEY and process.env.DATABASE_URL. Each environment fills in its own STRIPE_KEY: development and staging hand it a test key that starts with sk_test, and production hands it a live key that starts with sk_live.](https://www.kirupa.com/build/images/shipping_to_production_config.png) These named values are called environment variables. The [Twelve-Factor App](https://12factor.net/config) guidelines have a great test for this. Could we make our code public right now without leaking a single password? If yes, our configuration is in the right place. Environments also explain the most famous sentence in software: ![A laptop proudly wears a gold medal that says Works on my machine!, while the production server next to it is on fire.](https://www.kirupa.com/build/images/shipping_to_production_my_machine.png) When something works on Wren's laptop and breaks in production, the cause is almost always a difference between the two environments. These are the three differences that would have bitten Wren's page: ![Three differences between Wren's laptop and production. Node version: 24 on the laptop, 20 in production. STRIPE_KEY: set in a .env file on the laptop, missing in production. Logo.png and logo.png: the same file on the Mac, different files on Linux.](https://www.kirupa.com/build/images/shipping_to_production_differences.png) Take a look at the last row. Out of the box, a Mac's file system treats `Logo.png` and `logo.png` as the same file, while the Linux computers most hosts run on do not. To make production less of a surprise, we'll pin our Node version, have our app check for every setting it needs when it starts, and let staging catch the rest. ## Letting a Robot Do the Deploy It's time to build the belt itself. What Wren wants is for every push to GitHub to kick off the same steps automatically: install the dependencies, run the tests, build the app, and deploy it. If any step fails, the belt stops, and the broken change never gets deployed. Here is what that will look like for two pushes on the same afternoon: ![Two pushes run through the same four steps: install, test, build, and deploy. The push at 2:14pm passes every step and goes live. The push at 3:40pm fails the test step, where one test about pickup days failed, so build and deploy are skipped and Wren gets an email.](https://www.kirupa.com/build/images/shipping_to_production_pipeline.png) The first push sails through. The second push has a bug that would have shown the wrong pickup days, and a test catches it. The deploy never happens, so customers keep using the working version, and Wren gets an email about the failed test. Checking every change automatically as it gets merged in is called **continuous integration** (aka **CI**). Shipping every change that passes straight to production is called **continuous deployment** (aka **CD**), and people usually say **CI/CD** for both. On GitHub, Wren can describe the whole belt in one file: ```yaml name: Test and deploy on: push: branches: [main] pull_request: jobs: ship: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: node-version: 24 - run: npm ci - run: npm test - run: npm run build - if: github.event_name == 'push' run: curl -fsS -X POST "$DEPLOY_HOOK&ref=$GITHUB_SHA" env: DEPLOY_HOOK: ${{ secrets.RENDER_DEPLOY_HOOK }} ``` This file goes in `.github/workflows/deploy.yml`, where GitHub Actions will find it. Every push to `main`, and every pull request, runs these steps in order on a fresh computer that GitHub sets up just for this run, so our build can't quietly depend on something that only exists on Wren's laptop. If `npm test` fails, the steps after it never run. The last step only runs for pushes to `main`. It asks our host to deploy by calling a secret address (a [deploy hook](https://render.com/docs/deploy-hooks)), and the `ref` part tells the host to deploy the exact commit that just passed the tests. Wren also sets the host's own auto-deploy to off, so this workflow is the only thing that can deploy. We'll come back to that secret address in a moment. ## Where Do the Passwords Go? Our workflow needs that deploy hook, and our app needs a payment key and a database password. Values like these, which let whoever holds them act as us, are called **secrets**. The scariest place for a secret is inside our code, because code gets pushed to GitHub, copied to laptops, and pasted into chats. GitGuardian scans public GitHub commits every year, and its [State of Secrets Sprawl 2026](https://www.gitguardian.com/state-of-secrets-sprawl-report-2026) report shows how often secrets end up there: ![Bars of new secrets that GitGuardian found in public GitHub commits each year: about 11 million in 2021, 14 million in 2022, 18 million in 2023, 21 million in 2024, and 28.6 million in 2025.](https://www.kirupa.com/build/images/shipping_to_production_leaks_chart.png) That is **28,649,024** new secrets out in the open in 2025 alone, and of the working secrets GitGuardian found back in 2022, 64% still worked four years later. Deleting a leaked key from our code doesn't help much, since it lives on in Git's history and in every copy someone already made. The real fix is to cancel the leaked key and swap in a new one: ![Rotating a leaked key in three steps: cancel the leaked key ending in 4Ab, make a new key ending in 9Qz, and put the new key in the host's settings. The old key still sits in Git's history, but now it's useless.](https://www.kirupa.com/build/images/shipping_to_production_rotate.png) Swapping a key like this is called **rotating** it. Once the old key is canceled, the copy sitting in Git's history is worthless to whoever finds it. So, where should Wren's secrets live? There are three usual spots: ![Three places a secret can live. In the code, where it gets pushed to GitHub and copied everywhere, which is bad. In a .env file that Git ignores, which is fine on Wren's laptop only. In the host's and GitHub's secret settings, where it's encrypted and kept out of Git, which is where staging and production secrets belong.](https://www.kirupa.com/build/images/shipping_to_production_secret_spots.png) On Wren's laptop, a `.env` file that Git ignores is fine. For staging and production, the values go into the host's settings, and the deploy hook goes into GitHub's secrets (that's what `secrets.RENDER_DEPLOY_HOOK` in our workflow reads). GitHub hides those values in its workflow logs, but our own app should still never print a secret to its logs. [Security Basics for Builders](https://www.kirupa.com/build/security_basics.htm) goes deeper on keeping keys safe. ## What If a Deploy Goes Wrong Anyway? Tests catch a lot, but not everything. Let's say Friday's 9:05am deploy passes every check, and then customers start reporting that the Pay button does nothing on their iPhones. Wren's fastest move doesn't involve fixing anything yet. Most hosts keep every past deploy around, so Wren can put the previous one back: ![A host's deploy history. Deploy 43 from Friday at 9:05am is live, and its Pay button is broken on iPhones. Deploy 42 from Thursday at 4:30pm has a Roll back to this button, and one click puts it back. Deploy 41 from Thursday at 11:12am is below it.](https://www.kirupa.com/build/images/shipping_to_production_rollback.png) Putting a previous version back like this is called a **rollback**. It takes Wren one click, and it buys time to find the iPhone bug calmly instead of in full panic mode. Bigger launches will want more safety nets, like feature flags and rollouts that start with a few people, and [Launch Planning](https://www.kirupa.com/product_thinking/launch_planning.htm) covers those. ## What Changes When Agents Write the Code? All of this matters even more when an AI coding agent writes some of our code. An agent can open a new pull request every few minutes, and it can sound very sure about code that doesn't work. Luckily, our belt doesn't care who wrote a change: ![Changes from Wren and from a coding agent go through the same belt: tests, then a preview copy, then Wren merges what looks right, then production. The agent has no production secrets, so the belt is the only way in.](https://www.kirupa.com/build/images/shipping_to_production_agents.png) Every change runs the same tests and gets its own preview copy (many hosts build one for every pull request). Wren clicks through the preview and merges what looks right. We also won't give the agent our production secrets or a way to deploy by hand, so the belt is the only way the agent's code can reach production. ## Try It This Week Pick a small app you've built, or a brand new one with a single page, and put it on a conveyor belt: 1. Push it to a GitHub repository and connect that repository to a host. 2. Add a workflow that runs your tests and build on every push, and deploys only when they pass. 3. Break a test on purpose, push it, and make sure the deploy never happens. ## Frequently Asked Questions **What Does Deploying to Production Mean?** Production is the copy of an app that real customers use, running on a host that’s always on. Deploying (or shipping) to production means getting a new version of our code onto that host. A good deploy happens the same way every time, usually through an automated pipeline instead of by hand. **What Is the Difference Between Staging and Production?** Both run the same code. Staging is a private copy that uses test data and test keys, where we try a change before customers see it. Production uses real data and real keys, and it’s the copy customers use. **What Is CI/CD?** Continuous integration (CI) checks every change automatically as it’s merged, by installing, testing, and building it. Continuous deployment (CD) ships every change that passes straight to production. If a test fails, the pipeline stops, and the broken change never reaches customers. **Where Should I Store API Keys and Other Secrets?** Keep secrets out of your code. On your own laptop, a .env file that Git ignores is fine, and for staging and production, use your host’s secret settings and your CI system’s secrets, like GitHub Actions secrets. If a key ever leaks, rotate it, since deleting it from the code doesn’t remove it from Git’s history. ## Conclusion Ok! It's time to wrap things up. We started with a cake page that only worked on Wren's laptop, and we ended with a conveyor belt from laptop to world. There's a host that is always on, a name that points at it, environments that keep test things and real things apart, a CI/CD pipeline that checks every change, and secrets that stay out of our code. None of these pieces is hard on its own. Together, they turn shipping into something we can do many times a day without anybody holding their breath. We skipped a few things, like changing a database without losing orders, and those are worth learning when you get there. For now, our cake page goes out on Friday...and version two can go out on Saturday! Before you go, here are a few things you can do: 1. Test your knowledge by taking the quiz below. 2. Read the next article in the series, [Taking Payments](https://www.kirupa.com/build/taking_payments.htm), or check out some related content: - [Deploying Your React App](https://www.kirupa.com/react/deploying_react_apps.htm). Putting a Vite and React app on a static host, from build to live URL. - [Deploying an Agent](https://www.kirupa.com/ai_fundamentals/deploying_an_agent.htm). Endpoints, workers, and safe rollouts for an AI agent in production. - [Launch Planning: Sizing a Launch to Fit the Change](https://www.kirupa.com/product_thinking/launch_planning.htm). Feature flags, gradual rollouts, and rollback plans for bigger launches. 3. Stuck on something, or curious about a detail we skipped? [Ask on the forums](https://forum.kirupa.com/), and we’ll help you out. ## Test your knowledge! [Take the Reviewing Shipping to Production Quiz](https://www.kirupa.com/quizzes/shipping_to_production.htm). Practice with 6 multiple-choice questions and an explanation after every answer.