@inertiapixel/nextjs-auth
Version:
A reusable Next.js authentication package supporting credentials, OTP, and OAuth login.
18 lines (17 loc) • 433 B
JavaScript
// src/utils/tokenStorage.ts
export const getToken = (key) => {
if (typeof window !== 'undefined') {
return localStorage.getItem(key);
}
return null;
};
export const setToken = (key, token) => {
if (typeof window !== 'undefined') {
localStorage.setItem(key, token);
}
};
export const removeToken = (key) => {
if (typeof window !== 'undefined') {
localStorage.removeItem(key);
}
};