
In this fourth part of our Payload NextJS setup series, we'll walk through how to seamlessly integrate S3 object storage into your Payload project. This straightforward process will ensure your file uploads are efficient and reliable.
This step-by-step guide provides a comprehensive written walkthrough for integrating S3 object storage with your Payload CMS and NextJS application. For visual learners or those who prefer following along with video instruction, you can find the complete video tutorial on YouTube at the following link:
https://www.youtube.com/watch?v=25BCE_hx2yA
The video covers the same content but offers additional context and real-time demonstrations of each step in the process.
Integrating S3 storage into your Payload NextJS project enhances file management capabilities. With S3, you can store, retrieve, and manage files efficiently, ensuring your application scales without limitations. This guide will walk you through the steps to set up S3 storage, focusing on using Linode as your cloud provider.
To get started, you'll need a Linode account. If you don’t have one, visit the Linode website and sign up. Linode offers a referral link that gives new users $100 in credits for 60 days. This is a great way to explore their services without any initial costs.

Once your account is ready, log in and navigate to the object storage section. Here’s how to create your storage bucket:
Next, you'll need to create access keys that will allow your application to interact with the bucket. Follow these steps:
With your bucket and access keys ready, it's time to set up your Payload project. Open your terminal and navigate to your project directory. You will need to install necessary libraries for S3 integration:
npm install @payloadcms/plugin-cloud-storage
Make sure to check the documentation for any additional libraries you might need.

Environment variables are crucial for securely storing sensitive data such as access keys. Create a `.env` file in your project root and add the following variables:
The final step involves creating a storage adapter in your Payload configuration. This adapter connects your Payload project to the S3 storage. Here's how to set it up:
import s3Adapter from '@payloadcms/plugin-cloud-storage/s3';
plugins: [s3Adapter(config)]

Now that you've set up your Linode account and created a storage bucket, it’s time to integrate the Cloud Storage Plugin into your Payload NextJS project. This plugin will facilitate seamless interactions between your application and the S3 storage. Let’s dive into the integration process.
First, make sure you navigate to your project directory in the terminal. You’ll need to install the Cloud Storage Plugin for Payload. Use the following command:
npm install @payloadcms/plugin-cloud-storage
This command installs the necessary library to enable S3 storage in your Payload project.
With the plugin installed, the next step is to create a media collection that will utilize the S3 storage. This collection will allow you to upload and manage media files directly through your Payload dashboard.
To create a media collection, follow these steps:
export const media = {
slug: 'media',
labels: {
singular: 'Media',
plural: 'Media',
},
upload: true,
fields: [
{
name: 'file',
type: 'upload',
relationTo: 'media',
required: true,
},
],
};Ensure that the slug matches the one you configured in the cloud storage adapter. This consistency is essential for the integration to work smoothly.
Now that your media collection is set up, it’s time to test the file upload functionality. Start your development server by running the following command in your terminal:
npm run dev
Once the server is running, navigate to http://localhost:4000 in your web browser. You’ll need to create your first user to access the dashboard. After creating a user, log in to your Payload dashboard.
In the dashboard, select your media collection and click on Create New. Here, you can upload a file. Choose an image or any media file you want to test with.

After successfully uploading a file, it’s crucial to verify that the upload went through correctly. Head back to your Linode account and navigate to the object storage section.
Locate your basic setup bucket and check the contents. You should see the file you uploaded reflected here.
For example, if you uploaded an image, it should appear in the bucket with the corresponding size. You can click on the file to view its details or download it to ensure that it’s intact.
Congratulations! You’ve successfully integrated Payload NextJS with S3 object storage using Linode. This integration allows for efficient media management and enhances the capabilities of your application.
As a next step, consider exploring additional features of the Payload CMS. You can customize your media collection further by adding more fields or implementing different types of media handling. Additionally, make sure to monitor your storage usage and optimize your bucket settings as your application scales.
Payload NextJS is a flexible content management system that allows developers to create custom applications with ease. It provides a rich set of features for managing content, including file uploads and integrations with cloud storage providers.
S3 storage offers reliable, scalable, and cost-effective solutions for managing media files. Integrating S3 with Payload NextJS ensures that your application can handle large amounts of media without compromising performance.
Yes! Payload supports various cloud storage providers, including Google Cloud Storage and DigitalOcean Spaces. You can easily switch providers by configuring the appropriate adapter in your Payload setup.