Closed johannesschaffer closed 9 months ago
Ok, found the problem myself. The next-payload install
command isn't updated for v2. It creates an outdated payload config.
I'm gonna leave that issue open for now until it creates a correct payload config,
I was able to get things up and running with Next 14 and Payload 2 using the following config, based off of the errors thrown by the default config and some example configs in the documentation:
There were a few modules I had to install: @payloadcms/richtext-slate and @payloadcms/db-mongodb.
I also had to make sure that I had MongoDB installed on my computer (doh). Just throwing that out there because it's not actually stated in the README here that you should have it installed.
import path from 'path';
import { buildConfig } from 'payload/config';
import { BaseDatabaseAdapter } from 'payload/database';
import { Payload } from 'payload/dist/payload';
import { slateEditor } from '@payloadcms/richtext-slate';
import { mongooseAdapter } from '@payloadcms/db-mongodb'
export default buildConfig({
collections: [
{
slug: 'pages',
fields: [
{
name: 'title',
type: 'text',
required: true,
},
{
name: 'content',
type: 'richText',
required: true,
},
],
},
],
db: mongooseAdapter({
url: process.env.MONGODB_URI as string,
}),
editor: slateEditor({}),
globals: [
// Your globals here
],
typescript: {
outputFile: path.resolve(__dirname, '../payload-types.ts'),
}
});
After the next release this will work as you would expect when running yarn next-payload install
. Closing, thanks for reporting!
Just created a brand new project with Next.js 14. Can't open /admin. The error message
The same also goes for the api endpoints like '/api/[collection]/me', ...