browser.ts
OgBrowserSession
interface
A browser session that can render HTML pages to PNG.
Implements AsyncDisposable for automatic cleanup via await using.
openBrowser
function
Opens a Chromium browser and returns a session for rendering OG images.
Returns null if Playwright/Chromium is not available.
The session implements AsyncDisposable — use await using for automatic cleanup:
await using session = await openBrowser();
if (!session) return;
const png = await session.renderPage(html, 1200, 630);
export async function openBrowser(): Promise<OgBrowserSession | null>
Returns
Promise<OgBrowserSession | null> -