Payload requires a database to function, and in most cases, you'll also need a place to store your files. While Payload can store files on your local drive, this setup is not convenient for deployments, especially in serverless environments.
Supabase offers both a PostgreSQL database and multiple S3 storage buckets, making it an excellent choice for your project. Plus, Supabase's free plan provides a 500MB PostgreSQL database and 1GB of S3 storage, which should be sufficient for most small projects.
npx create-payload-app@beta
blank
template since we're not building a plugin.supabase-payload
, set a database password (you can generate one automatically), and choose your region (e.g., Frankfurt).cd supabase-payload
. And then open with VS Code: code .
npm run dev
Open http://localhost:3000
in your browser.Access the admin panel at: http://localhost:3000/admin
.
4. Create your first user: Follow the prompts to set up your admin user.
documents
collection:3. Ensure the configuration in payload.config.js: Add the following line to include your collection.
4. Adjust tsconfig.json if using JavaScript: If you're using JavaScript, you'll need to include JS files in your TypeScript configuration.
Add this to your Payload config and restart the server: npm run dev
Finally, verify data in Supabase—add some documents and check your Supabase database to ensure they are saved correctly.
Let's install the S3 plugin:
npm install @payloadcms/storage-s3
Since Payload is currently in beta (version 3 at the time of writing), you might encounter issues with peer dependencies. To resolve these, you can use the legacy-peer-deps
flag.
Alternatively, you could create an .npmrc
file consisting of legacy-peer-deps=true
.
I'm going to use it on a media collection, which we'll create shortly. We also need to give it a bucket name and a config with the accesskey, region, and endpoint. It's also important to force the path styles with Supabase.
3. Now let's create a media collection:
And now we need to add it to our Payload config.
4. Restart the server.
5. Setup a bucket in Supabase: Create a new bucket in Supabase named supabase-payload
and get your credentials (access key and secret access key).
6. Obtain your Supabase credentials:
supabase-payload
.7. Update environment variables: Add your Supabase credentials to your environment variables (.env)
:
Restart the server.
8. Upload an image: Test the setup by uploading an image through the Payload admin panel and verify the upload in your Supabase storage.
This should provide a clear and comprehensive guide. If you encountered any confusion in this guide, please check out the full YouTube video. Leave us any thoughts on Discord or in the comments of the video.