Set Up Your Jamstack Toolkit
By the end of this lesson you will have the Rohtak Tech Meetup project on your computer: created with Astro, running in a dev server, built into static files, saved in Git, and set up so secrets never leak. You will also know the folder layout that every later lesson in this course uses.
What you should know first: What Is the Jamstack?, how to open a terminal, and basic Git from Install & Configure Git. If Node.js is new to you, read Install Node.js. Versions checked on 16 November 2026: Astro 7.4.12 (from create-astro 5.3.2), Node.js 26.13.1, npm 11.21.2 and Git 2.56. Every output below comes from a real run on Windows; only the user name in paths was changed.
What you need
| Tool | Why | Version rule |
|---|---|---|
| Node.js | Runs Astro, Eleventy and the build | Astro 7.4 needs 22.23.4 or newer, even-numbered releases only |
| npm | Installs packages; comes with Node.js | Any version that ships with your Node.js |
| Git | Saves history; most hosts build from a Git repository | Any recent 2.x |
| VS Code (or any editor) | Editing .astro files | Install the official Astro extension |
| A modern browser | Testing and DevTools | Chrome, Edge or Firefox |
Node.js makes even-numbered releases (22, 24, 26) the long-term support lines, and Astro does not support odd-numbered ones like 23. Think of it like a train pass that is valid on express trains only: having a pass is not enough, it must be the right kind.
Step 1: check your tools
Open a terminal and run:
node -v
npm -v
git --versionv26.13.1 11.21.2 git version 2.56.0.windows.2
You can ask npm which Node.js versions a package accepts. This line from the package's own package.json is the real rule:
npm view astro engines{ npm: '>=9.6.5', node: '>=22.23.4', pnpm: '>=7.1.0' }This matters more than it looks. While preparing this lesson, a computer with Node.js 22.14.0 was too old for Astro 7.4, even though "22" sounds right. The check below compares versions part by part, the way npm does. Run it and try your own version.
// Is an installed Node.js version good enough for Astro?
function parse(version) {
return version.replace(/^v/, "").split(".").map(Number);
}
function isAtLeast(installed, required) {
const a = parse(installed);
const b = parse(required);
for (let i = 0; i < 3; i++) {
if (a[i] !== b[i]) return a[i] > b[i];
}
return true; // exactly equal
}
const required = "22.23.4"; // from: npm view astro engines
for (const installed of ["v22.14.0", "v22.23.4", "v23.11.0", "v26.13.1"]) {
let verdict = isAtLeast(installed, required) ? "OK" : "too old, please upgrade";
if (parse(installed)[0] % 2 === 1) {
verdict = "odd-numbered release, not supported";
}
console.log(`${installed}: ${verdict}`);
}v22.14.0: too old, please upgrade v22.23.4: OK v23.11.0: odd-numbered release, not supported v26.13.1: OK
Notice that "22.14.0" < "22.23.4" would also work here by luck, but comparing version strings as text breaks for "22.9.0" against "22.10.0". Always compare the numbers.
Step 2: create the project
Go to the folder where you keep projects and run:
npm create astro@latest -- rohtak-meetup --template minimal --no-install --no-gitnpm create astro@latest downloads and runs the create-astro tool. Everything after -- is passed to it: the folder name, the minimal starter (one empty page, nothing else), and "do not install or start Git yet". Without flags, it asks these questions one by one. We install separately because a slow connection can make the built-in install time out, which happened in our first attempt.
astro Launch sequence initiated.
◼ dir Using rohtak-meetup as project directory
◼ tmpl Using minimal as project template
◼ No problem! Remember to install dependencies after setup.
◼ Sounds good! You can always run git init manually.
✔ Project initialized!
■ Template copied
next Liftoff confirmed. Explore your project!
Enter your project directory using cd ./rohtak-meetup
Run npm run dev to start the dev server. q + ENTER to stop.
Add frameworks like react or tailwind using astro add.Step 3: install the dependencies
cd rohtak-meetup
npm installadded 184 packages, and audited 185 packages in 4m 69 packages are looking for funding run `npm fund` for details found 0 vulnerabilities
Those 184 packages go into node_modules/. They are tools for building the site. None of them is sent to visitors unless your pages import it.
Step 4: look at what you got
rohtak-meetup/
├── .vscode/
│ ├── extensions.json recommends the Astro extension
│ └── launch.json
├── node_modules/ installed packages (never edit, never commit)
├── public/
│ ├── favicon.ico
│ └── favicon.svg
├── src/
│ └── pages/
│ └── index.astro the home page
├── .gitignore
├── AGENTS.md notes for AI coding assistants (safe to delete)
├── astro.config.mjs Astro settings
├── package.json scripts and dependencies
├── package-lock.json exact installed versions
├── README.md
└── tsconfig.json editor type checkingOpen package.json. The scripts section gives you four commands: dev, build, preview and astro. The engines field repeats the Node.js rule from Step 1.
Step 5: run the dev server
npm run devastro v7.4.12 ready in 2520 ms ┃ Local http://localhost:4321/ ┃ Network use --host to expose 19:03:52 watching for file changes... 19:04:25 [200] / 316ms
Open http://localhost:4321/ and you see a heading that says "Astro". Edit the <h1> in src/pages/index.astro, save, and the browser updates by itself. The last line is a request log: status 200 for the home page. The dev server is only for you. It adds a small toolbar and debugging scripts that never appear in the real build. Stop it with Ctrl+C.
"use --host to expose" means the server listens only on your own computer. npm run dev -- --host lets a phone on the same Wi-Fi open it, which is handy for testing, but it also lets everyone on that network see your work in progress. Do not use it on public Wi-Fi.
Step 6: build and preview
npm run buildgenerating static routes 19:22:50 ├─ /index.html (+128ms) 19:22:50 ✓ Completed in 371ms. 19:22:50 [build] ✓ Completed in 5.49s. 19:22:50 [build] 1 page(s) built in 14.30s 19:22:50 [build] Complete!
The build writes plain files into dist/. That folder is your whole website: you could upload it to any static host. To check it exactly as visitors will get it, run npm run preview, which serves dist/ on the same port:
astro v7.4.12 ready in 603 ms ┃ Local http://localhost:4321/ ┃ Network use --host to expose
Step 7: the folder layout for this course
The minimal starter has one page. Over the next lessons it grows into this layout. Every later lesson follows it, so it is worth learning now.
rohtak-meetup/
├── public/ copied to the output as is (favicon, robots.txt)
├── src/
│ ├── components/ reusable pieces: SiteHeader.astro, EventCard.astro
│ ├── data/ events.json, our event list for now
│ ├── layouts/ BaseLayout.astro, the page shell
│ ├── lib/ plain JavaScript helpers: format.js
│ ├── pages/ one file = one URL
│ │ ├── index.astro -> /
│ │ └── events/
│ │ ├── index.astro -> /events/
│ │ └── [slug].astro -> /events/<slug>/
│ └── styles/
│ └── global.css
├── .env secrets and settings, never committed
├── astro.config.mjs
└── package.jsonNaming rules used in this course: components and layouts in PascalCase.astro, URLs and data slugs in kebab-case (such as git-for-beginners-jan-2027), JSON keys in camelCase (startTime), two-space indentation, double quotes and semicolons in JavaScript. Dates are stored as "2026-12-12" and formatted for India at build time.
Step 8: save it in Git
The starter's .gitignore already lists the things that must not be committed:
# build output
dist/
# generated types
.astro/
# dependencies
node_modules/
# environment variables
.env
.env.production(Some log and editor lines are left out here.) Now start the repository and make the first commit:
git init -b main
git add .
git commit -m "Start Rohtak Tech Meetup site with Astro minimal template"Initialized empty Git repository in C:/Users/meera/projects/rohtak-meetup/.git/ [main (root-commit) 68cd032] Start Rohtak Tech Meetup site with Astro minimal template 12 files changed, 4031 insertions(+)
On Windows, Git may also print several "LF will be replaced by CRLF" warnings during git add. They are about line endings, not errors; .gitattributes & Line Endings explains how to settle them. Notice that node_modules/ and dist/ were not committed. A host rebuilds them from package.json and your source.
Secrets and environment variables
Sooner or later the site needs settings, such as the organisers' public email or a key for an email-sending service. Put them in a file called .env in the project folder:
PUBLIC_RSVP_EMAIL=hello@rohtak-meetup.example
MAILER_API_KEY=demo-not-a-real-keyAstro reads them with import.meta.env. The rule is simple: names that start with PUBLIC_ may reach the browser; other names stay in server-side and build-time code. We tested it with a page whose frontmatter checked the key and whose <script> tried to read both:
---
const fromServer = import.meta.env.MAILER_API_KEY ? "secret is readable here" : "no secret";
---
<p id="a">{import.meta.env.PUBLIC_RSVP_EMAIL} | {fromServer}</p>
<p id="b"></p>
<script>
document.getElementById("b").textContent =
`${import.meta.env.PUBLIC_RSVP_EMAIL} | ${import.meta.env.MAILER_API_KEY}`;
</script>The built HTML in dist/ contained:
<!DOCTYPE html><p id="a">hello@rohtak-meetup.example | secret is readable here</p><p id="b"></p><script type="module">document.getElementById(`b`).textContent=`hello@rohtak-meetup.example | undefined`;</script>
The browser script got undefined for the secret, and a search of dist/ did not find the key anywhere. But be careful: frontmatter code runs at build time, and whatever it prints into the page becomes public HTML. Writing {import.meta.env.MAILER_API_KEY} in a static page would publish your key to the world. Secrets belong in serverless functions, which you will meet in Serverless Functions.
Common mistakes
- Wrong Node.js version. "22" is not enough; check the full version against
npm view astro engines. - Committing
.envornode_modules/. Keep the starter's.gitignore. If a key was ever committed, change the key, because Git history keeps it. - Uploading the project folder instead of
dist/. Visitors need the built output, not your source. - Testing only in the dev server. Run
buildandpreviewbefore you deploy; some problems appear only in the real build.
Interview questions
1. What is the difference between npm run dev and npm run build?
dev starts a local server that renders pages on request and reloads the browser when files change, with extra debugging tools. build renders every page once and writes the final static files to dist/, which is what gets deployed.
2. Why is package-lock.json committed but node_modules/ is not?
The lock file records the exact versions installed, so every machine and the host's build server install the same set. node_modules/ is large and can be recreated from the lock file with npm install (or npm ci on a build server).
3. How does Astro decide which environment variables reach the browser?
Only variables whose names start with PUBLIC_ are available to client-side code through import.meta.env. Others are available only in server-side and build-time code, but anything that code prints into a static page still becomes public.
Key points
- Check the full Node.js version against the package's
enginesrule; Astro 7.4 needs 22.23.4 or newer, even releases only. npm create astro@latestscaffolds the project;--template minimalstarts from one empty page.npm run devis for editing;npm run buildwrites the real site todist/;npm run previewserves that build.- The course layout:
components/,layouts/,pages/,data/,lib/andstyles/undersrc/. - Commit source and
package-lock.json; never commitnode_modules/,dist/or.env. - Only
PUBLIC_variables reach browser code, and anything printed into a static page is public.
Exercise
Set up the project yourself and prove each step worked. Create rohtak-meetup with the minimal template, install it, change the home page heading to "Rohtak Tech Meetup", run a build, and commit. Then add a .env file with PUBLIC_CITY=Rohtak and show the city on the home page. Finally, run git status and check that .env is not listed.
Show solution
npm create astro@latest -- rohtak-meetup --template minimal --no-install --no-git
cd rohtak-meetup
npm install
npm run build
git init -b main
git add .
git commit -m "Start Rohtak Tech Meetup site"In src/pages/index.astro, change the heading and use the public variable:
<h1>Rohtak Tech Meetup</h1>
<p>Meetups in {import.meta.env.PUBLIC_CITY}</p>If the city does not appear in the dev server, stop it and run npm run dev again so it reads the new .env file. git status does not show .env because the starter's .gitignore lists it. The variable is safe to show because it has the PUBLIC_ prefix and is not a secret.
Quick Quiz
1. Which Node.js version can run Astro 7.4.12?
Astro 7.4 needs 22.23.4 or newer and does not support odd-numbered releases.
2. Which folder do you deploy after npm run build?
The build writes the finished static site into dist/.
3. A <script> in an Astro page reads import.meta.env.MAILER_API_KEY. What does it get in the build?
Only variables starting with PUBLIC_ are available to client-side code.
4. Why should .env be in .gitignore?
Anything committed stays in history, so secrets must never be committed.
Learn Jamstack with a mentor
Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
