pnpm create astro@latest -- --template Rofisyahrul/astro-template
š§āš Seasoned astronaut? Delete this file. Have fun!
This starter kit implements colocation pattern to structure the project like this:
/
āāā integrations/ #custom astro integrations, should only be used in astro.config.mjs
āāā public/
āāā src/
ā āāā lib/
ā ā āāā components/ #shared components across pages, also use colocation patterns
ā ā ā āāā card/ #shared card component dir
ā ā ā ā āāā components/ #components those are directly rendered in the card.astro
ā ā ā ā āāā card.astro #shared card component
ā ā ā āāā chip.svelte #shared chip component
ā ā āāā pages/ #colocated pages modules
ā ā ā āāā dashboard/ #example of dir that categorized some pages modules
ā ā ā ā āāā lib/ #shared modules across the categorized pages (re: dashboard pages)
ā ā ā ā āāā pages/ #colocated pages modules for dashboard
ā ā ā ā āāā page-a/
ā ā ā ā āāā page-b/
ā ā ā āāā home/ #example of standalone page modules
ā ā ā āāā components/ #colocated components those are directly rendered in the home.astro
ā ā ā āāā lib/ #shared modules across home/*
ā ā ā āāā home.astro
ā ā ā āāā _script.server.ts #server side script executed in the page route level
ā ā āāā styles/ #global styles (scss/css/less files)
ā ā āāā types/ #shared type definitions
ā ā āāā utils/ #shared utility functions
ā ā āāā _document.astro #reusable document to wrap each pages
ā ā āāā _script.client.ts #global client side script
ā āāā middleware/ #astro middleware
ā ā āāā index.ts
ā āāā pages/ #astro page routes
ā ā āāā index.astro #execute home/_script.server.ts and render home/home.astro
ā āāā env.d.ts #global and Astro.locals type definitions
āāā astro.config.ts
āāā package.json
āāā tsconfig.json
Astro looks for .astro
or .md
files in the src/pages/
directory. Each page is exposed as a route based on its file name.
Any static assets, like images, can be placed in the public/
directory.
The global styles and the global client side script are injected through integrations/global-injector
.
All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
pnpm install |
Installs dependencies |
pnpm run dev |
Starts local dev server at localhost:4321 |
pnpm run build |
Build your production site to ./dist/ |
pnpm run preview |
Preview your build locally, before deploying |
pnpm run astro ... |
Run CLI commands like astro add , astro check |
pnpm run astro -- --help |
Get help using the Astro CLI |
Feel free to check our documentation or jump into our Discord server.