Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go
581 B
Raw Blame
import type { StorageAdapter } from "../types/storage";

/** SSR-safe localStorage. Works in both Next.js (SSR) and Electron (always client). */
export const defaultStorage: StorageAdapter = {
  getItem: (k) =>
    typeof window !== "undefined" ? localStorage.getItem(k) : null,
  setItem: (k, v) => {
    if (typeof window !== "undefined") localStorage.setItem(k, v);
  },
  removeItem: (k) => {
    if (typeof window !== "undefined") localStorage.removeItem(k);
  },
  keys: () => {
    if (typeof window === "undefined") return [];
    return Object.keys(localStorage);
  },
};