astro-template

Astro Template

A starter kit using Astro with Svelte, Tailwind, complete linter setup, complete SEO setup and service worker

Astro Starter Kit by RofiSyahrul

pnpm create astro@latest -- --template Rofisyahrul/astro-template

šŸ§‘ā€šŸš€ Seasoned astronaut? Delete this file. Have fun!

šŸš€ Project Structure

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.

šŸ§ž Commands

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

šŸ‘€ Want to learn more?

Feel free to check our documentation or jump into our Discord server.

Top categories

Loading Svelte Themes