ITEnthusiasm
05/06/2022, 5:26 PMsupertokens-website
could be made more functional in nature? I'm starting to see that for SSR frameworks (e.g., Svelte-Kit, Next, Nuxt, Remix), SuperTokens.init()
can get a little difficult because window.fetch
needs to exist. But window
doesn't exist on the backend.
It doesn't make sense to call SuperTokens.init()
from within another frontend function that's intended to be used multiple times (because then init
would be called several times when it only needs to be called once). So it has to be used in a more "open" area. But SuperTokens.init()
also can't easily be placed in a location that's too open or the SSR aspect of the framework will error out due to window
being undefined
.
If it was more functional, maybe a function could be returned that grabs all the things we need (e.g., modifications to fetch)? I'm not sure how feasible that is. Or perhaps there are workarounds to the problem that I haven't considered. But many of these workarounds seem a bit hackish/unorthodox.