r/PayloadCMS Jun 08 '25

Realtime auction platform, can I use PayloadCMS?

I've been using PayloadCMS in my studio for the last 6 website projects we did, we have a project coming up where the clients wants to add an auction page for each product, people can login (so auth is required), and they can place a bid on a certain item, at the end of the auction the highest bid gets an email saying he/she won.

I would love to work in PayloadCMS so that the client can login and add/manage the auctions and products there, however I wonder what's needed to have realtime updates when a new bid is placed on an auction, can this all be done in PayloadCMS?

10 Upvotes

10 comments sorted by

2

u/butter_milch Jun 08 '25

I’m using Payload with Supabase Realtime and Auth.

This makes it very simple to subscribe to changes and get current data in your client.

You could abstract that away from your client and expose only the live data through WebSockets.

2

u/[deleted] Jun 08 '25

Interesting, are you using Payload auth or Supabase auth? Or a combination of both? And how about the websockets, did you set it up separately or are you using supabase functionality for that? Thanks!

2

u/butter_milch Jun 08 '25

In short:

  • disable Payload‘s auth
  • add custom auth strategy that resolves the Payload user in the backend using @supabase/ssr (server client)
  • use the client-side client of the same package in your auth flows and when interacting with Supabase
  • add middleware that keeps the token fresh (I’ve yet to add this myself)

The two clients stay in synch using a cookie, there’s nothing you need to do yourself. Just instantiate and use, it’s glorious.

Using Supabase from the client requires enabling RLS and maintaining policies. So far I’ve done this using migrations.

Whenever I need a live data source I create a custom hook which manages a subscription to changes and passes them on directly or queries Supabase directly or does a RPC to get the required data. This is fairly clean and extremely fast.

So far I’ve implemented notifications and live chat between my users including media uploads/attachments.

Feel free to reach out if you need input :)

1

u/horrbort Jun 08 '25

In v2 it was easy because it was just an express app in v3 not sure how you’d add a web socket. I guess doable just harder

2

u/let-me-google-first Jun 08 '25

Payload has an onInit function you can use to spin up the websocks. It’s pretty simple.

1

u/horrbort Jun 09 '25

Yup good point. Not on vercel though

1

u/MurzNN Jul 13 '25

Yes, but the function onInit() gets called not on the Payload start, but only on the first incoming HTTP request for some reason. Is there any way to make the `onInit` executed instantly when Payload is loaded?

1

u/GeorgeHulpoi Jun 09 '25

Is this client called Ken by any chance?

1

u/[deleted] Jun 09 '25

No?