Svelte livepreview

default discord avatar
4 weeks ago

Hi all,

I'm trying to create a svelte hook to use livepreview within my svelte app. I managed to get the subscription function to work, now every time when I update the page within Payload the mergedData logs to the console. This is working fine, somehow the mergedData contains the none-updated data, even when I'm updating the data and mergedData gets logged to the console it shows the none-updated data within the mergedData object. Clicking the save button within the CMS will update the data to the actual state.

I'm trying to figure out where the problem could be. This is my onChange function and subscription method.

const onChange = (mergedData) => {
        console.log(mergedData, 'mergedData');

  const subscription = subscribe({
      callback: onChange,

payload version: 2.0.0

node: v19.9.0

Using the PostgresSQL connection

Fixed it, I was passing in the wrong server URL in the frontend. Should just be the payload server url. In my case:

    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!


    Connect with the Payload Community on Discord



    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.