sveltekit-preview-mode icon indicating copy to clipboard operation
sveltekit-preview-mode copied to clipboard

Sideffects in Load caused by Preview store.

Open bertybot opened this issue 9 months ago • 2 comments

Problem

Sveltekit docs recommend against using stores on the server as they can be exposed to other users unintendedly. The current way the isPreview store is implemented falls victim to this, and is a risk to people who might want to use this package on a wider scale. You also get a warning from Sveltekit when using this package because of this.

Resolution

I would be happy to fix this problem but, want to discuss the possible ways we implement this as it is going to be a breaking change and also might add more cognitive load to the package.

  1. We can do isPreview entirely in locals and make implementers responsible for passing that local to the PreviewBanner component through a prop.
  2. We can have the PreviewBanner injected into the HTML response on the hook. (this is harder and less open)

Also this would most likely cause breaking changes as users would no long be able to use the Preview store as it is suggest and instead pass the local into their functions.

Conclusion

I would very much like this problem fixed and I would be happy to do it. It's just a pretty big breaking change and I want to make sure I coordinate before implementing a fix.

bertybot avatar Oct 02 '23 19:10 bertybot