Giter Club home page Giter Club logo

payload-remix-test's Introduction

Payload CMS and Remix monorepo

This is an example repository of how to set up Payload CMS for content management together with Remix, in such a manner that each application is divided into its own package (including the express server app).

The Payload instance is injected into Remix loaders and actions through request context. This way we are free to use the Payload Local API for data, user and authentication management, while avoiding payload having to be bundled together with the remix server build. With this setup you can even use the Payload Authentication middleware in your remix application.

What's inside?

This monorepo is using pnpm for package management. While it is an easy task to switch to yarn instead, setting this up with npm workspaces can be trickier. For monorepos we do recommend pnpm due to its ability to handle hoisting in a better way, which avoids dependency related issues.

Apps and Packages

  • /apps/cms: a Payload CMS application, which will act as our backend and admin interface
  • /apps/web: a Remix application, which will act as our frontend
  • /apps/server: a ExpressJS application that ties all our middleware, static file serving and routing needs together
  • /packages/ui: a stub React component library shared by both web and cms applications
  • /packages/shared: a package that all out apps use that contains shared dependencies, in order to reduce bundle sizes
  • /packages/eslint-config-custom: eslint configurations

Utilities

  • TypeScript for static type checking
  • ESLint for code linting
  • Prettier for code formatting
  • Turborepo for running monorepo builds and script in a DX friendly and parallel manner
  • Nodemon for running the express server while listening to file changes in the Payload CMS package

Setup

Get started by running pnpm install from the root of the monorepo. Create a /apps/server/.env file based on /apps/server/.env.example and add your connection string to MongoDB as well as a secret for PayloadCMS to use in order to keep your data secure.

Develop

To develop all apps and packages, run pnpm run dev from the root of the monorepo. This will start the express server that serves both the Remix and PayloadCMS applications. When saving file changes in the apps/cms package, the running express server will restart in order for the Payload CMS configuration changes to take effect. Remix is reloaded without restarting the express server by purging the node require() cache of previously imported Remix files.

Build

To build all apps and packages, run pnpm run build from the root of the monorepo. Turborepo will take care of running the build scripts in order so that packages depending on other monorepo packages is built last.

If you want, serve your production build with pnpm run serve from the root of the monorepo.

payload-remix-test's People

Contributors

xhomu avatar

Watchers

 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.