#Using Payload as a Package in a Monorepo

25 messages · Page 1 of 1 (latest)

hollow token
#

Long story short, I have an existing Next 15 front end website and an existing separate Next 15 API only site. Both access data via a package (plus a bunch of other packages to keep it all DRY). E.g. website can get products from the shared database and API can also get same products with same code.

So, now I come across Payload and realise want to replace my DIY CMS with it, but use Payload's Local API in both apps, therefore thinking Payload should be a created as a Package and imported to both.

Any thoughts how I'd go about this please?

tranquil owlBOT
wary ingot
#

You can just use it as a REST Api from one to another, doesn't have to be the local API?

hollow token
#

It would be cleaner to use Local API as wouldnt need to worry about auth.

tight owl
#

Any direction on this?
I am looking through the Astro example but still no clarity on how to achieve this.
I would also prefer to use Local api.

hollow token
#

Not so far... need help from core team i suspect....

tight owl
#

How are you deploying ur apps?
For my case i dont think i would be able to use localapi since the apps would be running on seperate instances.
but to use any rest client i have to import the generated payload type.
https://github.com/dkirchhof/payload-rest-client
https://github.com/r1tsuu/payload-enchants/tree/master/packages/sdk
But i am getting i type error. Invalid module name in augmentation, module payload cannot be found.
I am hoping to be able to generate the type file as a package in the monorepo

repo/
├─ apps/
│ ├─ payload/
│ │ ├─ payload-config.ts
│ ├─ next-app/
packages/
├─ ui/
├─ payload-type/
│ ├─ payload-type.ts

GitHub

Contribute to dkirchhof/payload-rest-client development by creating an account on GitHub.

GitHub

Payload 3.0 enchantment packages. Contribute to r1tsuu/payload-enchants development by creating an account on GitHub.

hollow token
#

i've had to move forward with payload installed in the web app and move the api app into the web app for the time being. I'll look at extracting back into monorepo as a chore instead as time is against me.

wary ingot
#

Im sure you could extract the local API out but honestly seems like you're doing more hardwork that necessary

torpid turret
deep hare
torpid turret
deep hare
torpid turret
#

when I go to localhost4321 is gives 404

torpid turret
torpid turret
#

@deep hare can you pls help one more time? I'm losing my mind here

#

I want to import this: i18n-iso-countries, but Astro won't have it ..

#

import countries from 'i18n-iso-countries';

imported using pnpm (cd to apps/payload)

deep hare
torpid turret
#

okay i had to redo the thing but now I don't know how I got the homepage working from within payload 😂

torpid turret
#

This repo is very annoying to work with tbf.. Everything is outdated and still on next15 (pre-patched version).... Half of the stuff is broken, the other half breaks immediatly upon updating..

torpid turret
#

got it working on 15.4.8 now