@spoolcms/nextjs
Version:
The beautiful headless CMS for Next.js developers
55 lines (54 loc) • 1.62 kB
TypeScript
/**
* Spool Live Updates Hook - Convex Version
* This provides real-time content updates for customer Next.js apps
*/
import React from 'react';
import { ConvexReactClient } from 'convex/react';
export interface LiveUpdate {
_id: string;
siteId: string;
event: 'content.created' | 'content.updated' | 'content.published' | 'content.deleted';
collection: string;
slug?: string;
itemId: string;
metadata?: {
title?: string;
author?: string;
tags?: string[];
};
timestamp: number;
}
export interface UseSpoolLiveUpdatesConfig {
apiKey?: string;
siteId?: string;
onUpdate?: (update: LiveUpdate) => void;
enabled?: boolean;
}
/**
* Hook for subscribing to Spool live updates
* This is what customers will use in their Next.js apps
*/
export declare function useSpoolLiveUpdates(config?: UseSpoolLiveUpdatesConfig): {
isConnected: boolean;
error: string | null;
updates: any;
latestUpdate: any;
};
/**
* Provider component that automatically sets up Convex connection to Spool's infrastructure
* Customers just need to wrap their app with this - no additional configuration required!
*
* Usage:
* import { SpoolLiveUpdatesProvider } from '@spoolcms/nextjs';
*
* <SpoolLiveUpdatesProvider>
* <YourApp />
* </SpoolLiveUpdatesProvider>
*/
export declare function SpoolLiveUpdatesProvider({ children }: {
children: React.ReactNode;
}): React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.CElement<{
client: ConvexReactClient;
}, React.Component<{
client: ConvexReactClient;
}, any, any>>;