Every command, project file and piece of syntax from the course on one page: components, routing, content, rendering, islands, navigation and server features.
Appendix B: Astro Cheat Sheet
One page with the commands, files and syntax from the whole course.
Keep it open while you build.
Commands
Command
What it does
npm create astro@latest
Start a new project
npm run dev
Dev server at http://localhost:4321
npm run build
Build the site into dist/
npm run preview
Serve dist/ locally
npx astro add <name>
Add an integration or adapter (preact, node, netlify, sitemap...)
npx astro check
Type-check every file
npx astro sync
Regenerate types for collections and astro:env
Project Files
Path
Purpose
src/pages/
Every file here is a route
src/layouts/
Page shells with <slot />
src/components/
Reusable .astro, .tsx, .jsx components
src/content.config.ts
Build-time content collections
src/live.config.ts
Live collections
src/middleware.ts
Code that runs before every on-demand request
src/actions/index.ts
Type-safe server functions
public/
Files copied as they are (favicon.svg, robots.txt)
astro.config.mjs
Site settings, integrations, adapter
Component Syntax
---
// Component script: runs on the server or at build time.
import Card from "../components/Card.astro";
interface Props { title: string; tags?: string[] }
const { title, tags = [] } = Astro.props;
---
<h1 class:list={["title", { big: tags.length > 2 }]}>{title}</h1>
{tags.length > 0 && <ul>{tags.map((t) => <li>{t}</li>)}</ul>}
<Card title="Hi"><p>Default slot</p><p slot="footer">Named slot</p></Card>
<slot />
<style>
h1 { color: navy; } /* scoped to this component */
</style>
<script>
console.log("Runs in the browser, bundled once");
</script>
Routing
File
URL
src/pages/index.astro
/
src/pages/about.astro
/about
src/pages/posts/[slug].astro
/posts/anything (needs getStaticPaths() when static)