Coder Social home page Coder Social logo

next-payload-demo's Introduction

Important

This package only works with Next.js 13. The Payload team has attempted to troubleshoot why this package doesn't work with Next.js 14, but can't resolve the issues. Instead of continuing to focus on this package's compatibility with Next.js 14, we are going to prioritize work on moving Payload fully to Next.js—at which point, this package will no longer be relevant and everything will just work out of the box. If you would like to use this package in the meantime as we work to launching Payload + Next.js native support, you can do so as long as you are running Next.js 13.

Important

Also, we regenerate package-lock.json and ./node_modules on install as there is a bug that affects optional dependencies, affecting build and execution of platforms with different architectures than the developers platform. See this issue for more details.

Next + Payload Serverless Demo

This is a demo showing how to utilize @payloadcms/next-payload to deploy Payload serverlessly, in the same repo alongside of a NextJS app.

Developing locally

To develop with this package locally, make sure you have the following required software:

  1. MongoDB
  2. Node + NPM / Yarn
  3. An S3 bucket to store media

Getting started

Follow the steps below to spin up a local dev environment:

  1. Clone the repo
  2. Run yarn or npm install
  3. Run cp .env.example .env and fill out all ENV variables as shown
  4. Run yarn dev to start up the dev server

From there, you can visit your admin panel via navigating to http://localhost:3000/admin. Go ahead and start working!

Deploying to Vercel

The only thing you need to do to deploy to Vercel is to ensure that you have a Mongo Atlas database connection string and an S3 bucket available. Fill out the same environment variables that are shown in the .env.example with your own values, and then you're good to go!

Known gotchas

Cold start delays

With the nature of serverless functions, you are bound to encounter "cold start" delays when your serverless functions spin up for the first time. Once they're "warm", the problem will go away for a few minutes until the functions become dormant again. But there's little that this package can do about that issue, unfortunately.

If you'd like to avoid cold starts with your Payload API, you can deploy on a server-based platform like Payload Cloud instead.

Need to sign up for additional vendors

To deploy Payload on Vercel, you'll need to configure additional vendors for the following:

  • Database (MongoDB Atlas)
  • File storage (AWS S3 or similar) with Payload's Cloud Storage Plugin
  • Email service (Resend, Sendgrid)

If you don't want to go out and sign up for a separate file hosting service, you can just use Payload Cloud, which gives you file storage, a MongoDB Atlas database, email service by Resend, and lots more.

next-payload-demo's People

Contributors

jacobsfletch avatar jarrodmflesch avatar jeepman32 avatar jmikrut avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.