UNPKG

sanity-plugin-seo

Version:

Complete SEO toolkit for Sanity Studio with live scoring, AI suggestions, team workflows, and 30+ structured data types. Free and AI tiers live. Pro coming soon.

21 lines (17 loc) 719 B
import { useState, useEffect } from "react"; import { isProEnabled, isLicenseValidating, SEO_PRO_EVENT } from "../config"; export default function useProEnabled(): { isPro: boolean; validating: boolean } { const [isPro, setIsPro] = useState(isProEnabled()); const [validating, setValidating] = useState(isLicenseValidating()); useEffect(() => { const handler = () => { setIsPro(isProEnabled()); setValidating(isLicenseValidating()); }; window.addEventListener(SEO_PRO_EVENT, handler); // Sync immediately in case validation already finished before mount handler(); return () => window.removeEventListener(SEO_PRO_EVENT, handler); }, []); return { isPro, validating }; }