createStore¶
Import¶
Function Signature¶
createStore<T
>(params
): createStoreReturn
<T
>
createStore creates the default store for React Auth Kit.
This store is like a Redux store, where every object and data is stored.
Type Parameters¶
Name | Description |
---|---|
T |
Type of User State Object |
Parameters¶
Name | Type | Required | Description |
---|---|---|---|
authName |
string |
This name will also be used as a prefix for all other cookies. | |
authType |
string |
Type of the Storage. Options : cookie , localstorage |
|
cookieDomain |
string |
Domain of the cookie, for which the cookie is valid. Needed if you are using cookie as authType |
|
cookieSecure |
boolean |
Indicating if the cookie transmission requires a secure protocol (https). Needed if you are using cookie as authType |
|
refresh |
createRefreshParamInterface<T> |
Refresh API. Created using createRefresh function. |
Returns¶
Auth Kit Store
Example¶
Here is an example on JavaScript
import createStore from 'react-auth-kit/createStore';
const store = createStore({
authName:'_auth',
authType:'cookie',
cookieDomain: window.location.hostname,
cookieSecure: window.location.protocol === 'https:'
})
Here is an example on TypeScript
interface IUserData {
name: string;
uuid: string;
};
const store = createStore<IUserData>({
authName:'_auth',
authType:'cookie',
cookieDomain: window.location.hostname,
cookieSecure: window.location.protocol === 'https:'
})
Defined in¶
packages/react-auth-kit/src/createStore.ts:96
— 🔑 —
React Auth Kit is MIT License code