Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | // Type definitions for Coherent.js Next.js Integration
import { NextApiRequest, NextApiResponse } from 'next';
import { ReactNode } from 'react';
import { CoherentNode } from '../coherent';
export interface CoherentNextHandlerOptions {
/**
* Enable performance monitoring for rendered components
* @default false
*/
enablePerformanceMonitoring?: boolean;
/**
* HTML template to wrap rendered components
* @default '<!DOCTYPE html><html><body>{{content}}</body></html>'
*/
template?: string;
/**
* Enable streaming rendering for large components
* @default false
*/
enableStreaming?: boolean;
}
/**
* Create a Next.js API route handler for Coherent.js components
* @param componentFactory Function that returns a Coherent component
* @param options Configuration options
* @returns Next.js API route handler
*/
export function createCoherentNextHandler(
componentFactory: (req: NextApiRequest, res: NextApiResponse) => CoherentNode | Promise<CoherentNode>,
options?: CoherentNextHandlerOptions
): (req: NextApiRequest, res: NextApiResponse) => void;
/**
* Create a Next.js App Router route handler for Coherent.js components
* @param componentFactory Function that returns a Coherent component
* @param options Configuration options
* @returns Next.js App Router handler
*/
export function createCoherentAppRouterHandler(
componentFactory: (request: Request) => CoherentNode | Promise<CoherentNode>,
options?: CoherentNextHandlerOptions
): (request: Request) => Promise<Response>;
/**
* Create a Next.js Server Component for Coherent.js
* @param componentFactory Function that returns a Coherent component
* @param options Configuration options
* @returns Next.js Server Component
*/
export function createCoherentServerComponent(
componentFactory: (props: any) => CoherentNode | Promise<CoherentNode>,
options?: {
enablePerformanceMonitoring?: boolean;
enableStreaming?: boolean;
}
): Promise<(props: any) => Promise<ReactNode>>;
/**
* Create a Next.js Client Component for Coherent.js with hydration support
* @param componentFactory Function that returns a Coherent component
* @param options Configuration options
* @returns Next.js Client Component
*/
export function createCoherentClientComponent(
componentFactory: (props: any) => CoherentNode,
options?: {
enablePerformanceMonitoring?: boolean;
enableHydration?: boolean;
}
): (props: any) => ReactNode;
/**
* Render a Coherent component to HTML string
* @param component Coherent component to render
* @param options Rendering options
* @returns Rendered HTML string
*/
export function renderComponent(
component: CoherentNode,
options?: CoherentNextHandlerOptions
): string;
/**
* Default export with all utilities
*/
declare const coherentNext: {
createCoherentNextHandler: typeof createCoherentNextHandler;
createCoherentAppRouterHandler: typeof createCoherentAppRouterHandler;
createCoherentServerComponent: typeof createCoherentServerComponent;
createCoherentClientComponent: typeof createCoherentClientComponent;
renderComponent: typeof renderComponent;
};
export default coherentNext;
|