Would it be so bad to use global state for authentication?
💙Beginner🎏SuggestionsSolid API
ATM I use
createContext
createContext
to distribute a function that wraps
fetch
fetch
with authentication.
At the time I set that up, I didn't understand SolidJS well enough to be confident in breaking recommendation.
Now though, I really can't see why I shouldn't have global state for this, after all, to the user it is supposed to be global state, and nothing needs to be reactive to changes in authentication.
The downside is that it means the authentication system cannot handle authentication failure on it's own, but this really wouldn't be very hard to work around.
In fact, I could argue that global state makes more sense that context here, because why should UI components be responsible for injecting authentication into the code that interacts with the backend?