This is a template for Payload CMS and Astro It is a simple blog template with a few pages and a blog post collection. It is fully typed with TypeScript.
- Clone this repository
- Run
npm install
- set
MONGODB_URI
inbackend/.env
with a MongoDB connection string (run locally or use a service like MongoDB Atlas) - Run
cd backend && npm run dev
to start the development server for payload - In another terminal run
cd frontend && npm run dev
to start the development server for astro
After changing any of the payload config in backend/src/payload.config.ts
you will need to regenerate the types for the frontend. To do this, run npm run generate:types
in the backend
directory. Then add fetch functions with the new types to frontend/src/api.ts
To deploy this template, there are a couple of options.
The frontend and backend can be deployed separately. The frontend can be deployed to any static hosting service like Netlify or Vercel or CloudflarePage. The backend can be deployed to any Node.js hosting service like Heroku or Vercel.
The frontend and backend can be deployed together. Astro can be run as a node service with SSR enabled and can be called from the backend in the backend/src/server.ts
file.