Skip to content

[SSR] Library isn't compatible with SSR and shares its state between all the clients #94

@mattersj

Description

@mattersj

Solid-toast creates a store in global scope which is literally just a global variable that's created only once on the server and being shared across all the clients afterwards:

const [store, setStore] = createStore<State>({

Reproduction: https://stackblitz.com/edit/solid-ssr-vite-n1tsrb?file=src%2Froutes%2Findex.tsx,src%2Froot.tsx

  1. Open reproduction and wait till a toast is popped up.
  2. Update the page after this.

As you can see, a toast pops up immediately even though we have a timer set up for this. A toast will still be there even if you comment out this timer and update the page one more time.

I think it makes sense to leverage Context API here and create independent store for every provider, but probably this would require some breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions