How to handle auth

I’m doing rescript yet again, but in a slightly bigger project. This time, I’m starting with auth because… yes?

But I’m kinda lost on implementation details. How should I do something that is very mutable (and non-functional programming) + How can I integrate that with react (that part I know, but with js, not rescript).

I tried contexts with the following code, but I remembered that it should be immutable in rescript, so I don’t know how that would be possible.

type t =
  | Guest
  | Authenticated // TODO: of User

let context = React.createContext(Guest)

module Provider = {
  let make = React.Context.provider(context)
}

What’s the recommended way of doing auth in rescript? Is there any examples of it?