react-unique-id-generator
Version:
A lightweight, zero-dependency library for generating unique, sequential IDs in React — with hooks, custom prefix/suffix, SSR support, and stable CSS selector generation
23 lines • 950 B
TypeScript
import { type ReactNode } from 'react';
export interface SSRContextValue {
nextId: (prefix?: string) => string;
resetId: () => void;
getCurrentId: () => number;
}
export interface SSRProviderProps {
prefix?: string;
suffix?: string;
requestId?: string;
children: ReactNode;
}
declare const SSRContext: import("react").Context<SSRContextValue | null>;
export declare function useSSRContext(): SSRContextValue | null;
export declare function SSRProvider({ prefix, suffix, requestId, children, }: SSRProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<SSRContextValue | null>>;
export declare function useSSRSafeId(prefix?: string): string;
export declare function createSSRIdFactory(requestId: string, prefix?: string, suffix?: string): {
nextId(localPrefix?: string): string;
resetId(): void;
getCurrentId(): number;
};
export { SSRContext };
//# sourceMappingURL=ssr.d.ts.map