Deploy Your Project
What you'll learn
~20 min- Understand what deployment means and why it matters
- Deploy a project to Cloudflare Pages using the CLI
- Deploy alternatives: Vercel, Netlify, GitHub Pages
- Set up auto-deploy from GitHub pushes
- Troubleshoot common deployment failures
You’ll deploy a project to the internet — often in 5-15 minutes for first-time setup, much faster after that — so anyone with the URL can see it.
Why this matters
Building is only half the job. Sharing your project multiplies its impact and makes your work easier to showcase. Deployment is how you ship. It is the difference between “I built a thing on my laptop” and “here is the link — try it yourself.” Every project you deploy becomes a real portfolio piece, a shareable proof of work, and something you can point to in a job interview, a class presentation, or a grant proposal.
Mental model: the copy shop
Your project is the original document sitting on your laptop. A hosting platform (Cloudflare Pages, Vercel, Netlify, GitHub Pages) is a copy shop: you hand it the original, and it prints and distributes copies to anyone who asks for them. The URL is the address you hand out so people can pick up their copy.
The best part? Modern copy shops are smart. You can set them up to watch your GitHub repository. Every time you update the original (push to GitHub), they automatically print a fresh version. That is auto-deploy — and it means you never have to manually deploy again after the first time.
Before you start
Make sure you have the following ready before deploying:
- Node.js and npm installed — verify with
node -vandnpm -v - Git installed and configured — verify with
git --version - Code pushed to a GitHub repository — if you need a refresher, see Module 7 Lesson 4
- A free account on your chosen hosting platform — Cloudflare, Vercel, Netlify, or GitHub Pages
Pre-deployment checklist
Before you deploy for the first time, run through this list:
- Does
npm run buildsucceed? Run it locally. If the build fails on your machine, it will fail on the hosting platform too. - No secrets in the code? Search your project for API keys, passwords, or tokens. They should be in
.env, not hardcoded in source files. Remember:.envis for local development only. For production, set environment variables in your hosting platform’s dashboard (Cloudflare, Vercel, or Netlify all have a settings page for this). Never upload.envto a hosting platform. - Is .gitignore correct? In most Node/web workflows,
node_modules/,.env, and build output likedist/orbuild/should all be excluded from git tracking. - Code pushed to GitHub? Your latest changes should be committed and pushed. If you need a refresher, see Module 7 Lesson 4: GitHub: Your Cloud Backup.
- Does the project look right? Run
npm run dev, open it in your browser, and click through the main pages and features.
If you have not completed Module 10 (Planning and Orchestration), you can still deploy — but Module 10 teaches you how to plan and iterate on projects effectively, which makes the deploy-fix-redeploy cycle much smoother.
The steps below work for static site generators and frameworks like Astro, Vite, and Create React App. If you are using a server-rendered framework (Next.js with SSR, Nuxt, SvelteKit), deployment requires platform-specific configuration — check your framework’s deployment docs for details.
Primary walkthrough: Cloudflare Pages
Cloudflare Pages is a great first choice. It is free, fast, and works with any static site or framework. Here is the full CLI walkthrough.
Step 1: Log in to Cloudflare
This opens your browser to authenticate with your Cloudflare account (sign up for free if you don’t have one). We use npx to run the Wrangler CLI without a global install, which avoids permission errors:
npx wrangler@latest loginStep 2: Build your project
Run the production build:
npm run buildThis creates a dist/ folder (for Astro/Vite projects) or build/ folder (for Create React App) containing the optimized files ready for deployment.
Verify the build output exists before deploying:
ls distIf you see a list of files (including index.html), you are ready. If you get “No such file or directory,” the build may have failed or your framework uses a different output folder (check build/ instead).
Step 3: Deploy
Send the built files to Cloudflare:
npx wrangler@latest pages deploy dist --project-name my-projectReplace my-project with a name for your site (lowercase, hyphens only). Replace dist with build if you are using Create React App.
Step 4: Visit your URL
Wrangler prints the URL when the deploy finishes. It looks like:
https://my-project.pages.devOpen it in your browser. Your project is live on the internet.
Login, build, deploy, visit. Every subsequent deploy is just two commands: npm run build and npx wrangler@latest pages deploy dist --project-name my-project.
Alternatives at a glance
Cloudflare Pages is not the only option. Here is a quick comparison:
| Platform | Best for | Free tier | CLI deploy command |
|---|---|---|---|
| Cloudflare Pages | Any static site, fast global CDN | Unlimited sites, 500 builds/month | npx wrangler@latest pages deploy dist |
| Vercel | React/Next.js apps | Free tier available | vercel --prod |
| Netlify | Static sites, forms, serverless | Free tier available | netlify deploy --prod |
| GitHub Pages | Simple static sites, portfolios | Unlimited (public repos) | Via git push (no separate CLI) |
All four are free for personal and learning projects and are solid choices for getting started. Choose based on your framework and needs. Free tier limits change over time — check each platform’s pricing page for current details.
Unlike Wrangler (which uploads your pre-built dist folder), Vercel and Netlify upload your source code and run the build on their servers. This means you do not need to run npm run build before deploying with their CLIs — they handle it. It also means builds may take a bit longer since they install dependencies from scratch.
Quick setup: Vercel
npx vercel loginnpx vercel # Follow the promptsnpx vercel --prod # Deploy to productionQuick setup: Netlify
npx netlify-cli loginnpx netlify-cli init # First time: link to a Netlify sitenpx netlify-cli deploy --prodQuick setup: GitHub Pages
No CLI install needed. Go to your repository on github.com, click Settings, then Pages, select the main branch, and save.
If your project uses Astro, React, Vite, or any framework that needs npm run build, selecting a branch alone will publish your raw source files — not the built site. You need a GitHub Actions workflow to build and deploy automatically. Open your AI CLI tool (such as Claude Code, Gemini CLI, or your preferred tool) and ask it to create a .github/workflows/deploy.yml file for your framework. Platform dashboard UIs change frequently, so verify the current steps in the GitHub Pages documentation.
Auto-deploy from GitHub
Manual CLI deploys work fine, but auto-deploy is the real goal. Here is the idea: connect your GitHub repository to a hosting platform once, and every git push automatically triggers a rebuild and deployment.
How to set it up
- Go to your hosting platform’s dashboard (Cloudflare, Vercel, or Netlify)
- Create a new project and choose “Import from GitHub”
- Select your repository and authorize access
- Configure build settings:
- Build command:
npm run build(orastro buildfor Astro projects — most frameworks supportnpm run buildas the standard command) - Output directory:
dist/(for Astro/Vite) orbuild/(for Create React App) or.next/(for Next.js)
- Build command:
- Save and deploy
Platform dashboard UIs change frequently. If any step looks different, check the platform’s current documentation: Cloudflare Pages docs, Vercel docs, Netlify docs.
From this point forward, the workflow is:
Make changes --> git add . --> git commit -m "description" --> git push --> Site auto-updatesNo manual deploy steps. Push to GitHub, wait 1-5 minutes (depending on build size and queue), and your live site reflects the changes.
Some tutorials suggest using localStorage or JavaScript to create a simple password gate. Do not use this for anything sensitive. Anyone can open browser DevTools and bypass client-side checks in seconds. For real access control, use server-side authentication (like Cloudflare Access, Vercel Password Protection, or Netlify Identity) or keep the project in a private repo and share the URL only with authorized users.
Practice
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
🔍Custom domains
Every hosting platform gives you a free URL (like my-project.pages.dev or my-project.vercel.app). If you want a professional-looking URL like dashboard.yourdomain.com, you can buy a domain name (around $10-15/year from a domain registrar like Namecheap, Cloudflare Registrar, or Squarespace Domains) and connect it in your hosting platform’s domain settings. The platform handles SSL certificates automatically. This is optional — the free URLs work perfectly for sharing and portfolios.
Use cases and considerations
🧬In Your Field: Biotechclick to expand
Sharing research tools with your lab. Deploy your data visualization tool or lab calculator and share the link with collaborators. A live URL is much easier to share than “clone my repo and run npm install.” Your PI can open the tool on their phone during a meeting. Collaborators at other institutions can use it without any setup.
🏛️In Your Field: Government / State Devclick to expand
Government deployment considerations. State agencies may have restrictions on which hosting platforms are approved. Check with your IT department before deploying agency tools to external platforms. For internal tools, your agency may have an approved hosting environment. For personal portfolio projects or open-source civic tools, the free platforms listed here work well.
📊In Your Field: MIS / Businessclick to expand
Deploying business dashboards. For internal dashboards, you may want a private deployment. Vercel and Netlify both support password-protected deployments on paid plans. For a free alternative, keep the GitHub repository private and only share the deployment URL with authorized users.
Key takeaways
- Deployment is how you ship. A project on your laptop is invisible. A project with a URL is real.
- Build locally before deploying. Run
npm run buildfirst. Fix errors on your machine, not on the hosting platform. - Cloudflare Pages is a great default. Login, build, deploy, visit. Done.
- All four platforms are free and work well. Cloudflare Pages, Vercel, Netlify, and GitHub Pages all have free tiers for learning projects. Pick whichever feels simplest.
- Auto-deploy is the goal. Connect GitHub to your hosting platform once, and every
git pushupdates the live site automatically.
After connecting your GitHub repo to a hosting platform, what happens when you push new changes?