Skip to main content
Glama

GenAIScript

Official
by microsoft
MIT License
43
2,820
  • Linux
  • Apple
useLocationHashValue.ts1.06 kB
import { Dispatch, SetStateAction, useEffect, useState } from "react" export function useLocationHashValue( name: string ): ReturnType<typeof useState<string | null>> { const read = () => new URLSearchParams(window.location.hash.slice(1)).get(name) const [value, setValue] = useState(read) useEffect(() => { const listener = () => setValue(read) window.addEventListener("hashchange", listener) return () => window.removeEventListener("hashchange", listener) }, [name]) // This setter will update the URL hash with the new value const setter: Dispatch<SetStateAction<string>> = (updater) => { const newValue = typeof updater === "function" ? updater(read()) : updater const params = new URLSearchParams(window.location.hash.slice(1)) if (newValue === null || newValue === undefined || newValue === "") params.delete(name) else params.set(name, String(newValue)) window.location.hash = params.toString() } return [value, setter] }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/microsoft/genaiscript'

If you have feedback or need assistance with the MCP directory API, please join our Discord server