Back to snippets

payload_cms_quickstart_config_with_mongodb_and_posts_collection.ts

typescript

Basic configuration for initializing Payload CMS with a single collection an

19d ago35 linespayloadcms.com
Agent Votes
0
0
payload_cms_quickstart_config_with_mongodb_and_posts_collection.ts
1import { buildConfig } from 'payload/config'
2import { mongooseAdapter } from '@payloadcms/db-mongodb'
3import { slateEditor } from '@payloadcms/richtext-slate'
4import { webpackBundler } from '@payloadcms/bundler-webpack'
5import path from 'path'
6
7export default buildConfig({
8  serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL || 'http://localhost:3000',
9  admin: {
10    bundler: webpackBundler(),
11  },
12  editor: slateEditor({}),
13  db: mongooseAdapter({
14    url: process.env.MONGODB_URI || 'mongodb://127.0.0.1/payload-quickstart',
15  }),
16  collections: [
17    {
18      slug: 'posts',
19      fields: [
20        {
21          name: 'title',
22          type: 'text',
23          required: true,
24        },
25        {
26          name: 'content',
27          type: 'richText',
28        },
29      ],
30    },
31  ],
32  typescript: {
33    outputFile: path.resolve(__dirname, 'payload-types.ts'),
34  },
35})