react-auth-kit
Version:
Authentication Library for React, which makes Token based auth very easy
26 lines (25 loc) • 766 B
JavaScript
;
'use client';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.useReactAuthKit = useReactAuthKit;
var _react = require("react");
var _errors = require("./errors");
function getContext() {
var context = (0, _react.createContext)(null);
if (process.env.NODE_ENV !== 'production') {
context.displayName = 'ReactAuthKit';
}
return context;
}
var AuthKitContext = getContext();
function useReactAuthKit() {
var context = (0, _react.useContext)(AuthKitContext);
if (context === null) {
throw new _errors.AuthError('Auth Provider is missing. ' + 'Make sure, you are using this component inside the auth provider.');
}
return context;
}
var _default = exports.default = AuthKitContext;