userfront-core
userfront-core copied to clipboard
Add custom token getters and setters
Right now, tokens are set automatically and can be read with e.g. Userfront.tokens.accessToken. However, this assumes a browser context, so does not work with many SSR applications.
It would be good to have a way to specify getter and setter methods for the tokens, so that SSR applications can still use the library.
Potential API (nextjs example):
import Cookies from 'cookies'
Homepage.getInitialProps = ({ req, res }) => {
const cookies = new Cookies(req, res);
Userfront.tokens.getter = cookies.get
Userfront.tokens.setter = (name, value, options) => cookies.set(name, value, options)
}