@lelemondev/sdk - v0.9.9
    Preparing search index...

    Function withObserve

    • Wrap a Next.js App Router handler with automatic trace flushing

      Type Parameters

      • TContext = unknown

      Parameters

      Returns NextRouteHandler<TContext>

      Wrapped handler that auto-flushes traces

      // Basic usage (blocking flush)
      export const POST = withObserve(async (req) => {
      return Response.json({ ok: true });
      });
      // Next.js 15+ with after() - non-blocking (recommended)
      import { after } from 'next/server';

      export const POST = withObserve(
      async (req) => Response.json({ ok: true }),
      { after }
      );
      // Vercel with waitUntil() - non-blocking
      import { waitUntil } from '@vercel/functions';

      export const POST = withObserve(
      async (req) => Response.json({ ok: true }),
      { waitUntil }
      );