@inertiapixel/nextjs-auth
Version:
Authentication system for Next.js. Supports credentials and social login, JWT token management, and lifecycle hooks — designed to integrate with nodejs-auth for full-stack MERN apps.
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);
}
};