This pattern isn't needed since Astro now supports prerendering
Welcome to Astro SSG and SSR hybrid pattern for Cloudflare
Deploys an hybrid build to Cloudflare Pages allowing full content generation control
- Deploying a full SSR website isn't always optimal
- SSG is faster, cheaper, greener, and more reliable.
- SSR is sometimes required
- Cloudflare recommends the pattern
- Because Astro is abstract enough and we can
Build Astro with both targets and merge the result
Inside of this Astro project, you'll see the following folders and files:
├── public/
│ └── favicon.svg
│ └── _routes.json
├── src/
│ ├── components/
│ │ └── Card.astro
│ ├── layouts/
│ │ └── Layout.astro
│ ├── ssg/pages/
│ │ └── index.astro
│ │ └── 404.astro
│ └── ssr/pages/
│ └── ssr.astro
│ └── dilbert-ssr.astro
├── package.json
├── astro.config.base.mjs
├── astro.config.ssg.mjs
├── astro.config.ssr.mjs
└── astro.config.ssr.mjs
All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
npm install |
Installs dependencies |
npm run dev-ssg |
Starts local SSG dev server at localhost:3000 |
npm run dev-ssr |
Starts local SSR dev server at localhost:3000 |
npm run build |
Build your production site to ./dist/ |
npm run preview |
Preview your full build locally with Wrangler |
npm run watch |
Update build for preview |