#Connecting MongoDB
3 messages · Page 1 of 1 (latest)
Hi @hallow wedge. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To connect MongoDB to your Astro project, you can use PayloadCMS, a headless open-source content management system. Here are the prerequisites and steps to do so:
- An Astro project - If you don’t have an Astro project yet, the Installation guide (https://docs.astro.build/en/install/auto/) will help you set it up.
- A MongoDB database - PayloadCMS will ask you for a MongoDB connection string when creating a new project. You can set one up locally or use MongoDBAtlas (https://www.mongodb.com/) to host a database on the web for free.
- A PayloadCMS REST API - Create a PayloadCMS (https://payloadcms.com/docs/getting-started/installation) project and connect it to your MongoDB database during the setup.
During the PayloadCMS installation, you will be asked if you want to use a template. Choosing any of the available templates at this step (such as ‘blog’) automatically generates additional collections for you to use. Otherwise, you will need to manually create your PayloadCMS collections.