Skip to content

The platform for continuously improving AI agents.

432 B
Raw Blame
import { useSearch } from "@tanstack/react-router";

const SELECTED_PROJECT_STORAGE_KEY = "__selectedProject";

export function getActiveProjectId(): string {
  if (typeof localStorage === "undefined") return "";
  return localStorage.getItem(SELECTED_PROJECT_STORAGE_KEY) ?? "";
}

export function useConsoleProjectId(): string {
  const { projectId } = useSearch({ from: "/_auth" });
  return projectId || getActiveProjectId();
}