Skip to content

API Reference

Type-safe configuration helper:

import { defineConfig } from 'aeo.js';
export default defineConfig({
title: 'My Site',
url: 'https://mysite.com',
});

Generate all AEO files programmatically:

import { generateAll } from 'aeo.js';
await generateAll({
title: 'My Site',
url: 'https://mysite.com',
outDir: 'dist',
});

Resolve a partial config into a fully resolved config with defaults:

import { resolveConfig } from 'aeo.js';
const resolved = resolveConfig({ title: 'My Site' });
// All fields now have defaults

Validate a config object and return any errors:

import { validateConfig } from 'aeo.js';
const errors = validateConfig(config);

Auto-detect the framework used in the current project:

import { detectFramework } from 'aeo.js';
const info = detectFramework();
// { framework: 'next', contentDir: 'pages', outDir: '.next' }

Convert HTML to clean markdown:

import { htmlToMarkdown } from 'aeo.js';
const md = htmlToMarkdown('<h1>Hello</h1><p>World</p>');
// '# Hello\n\nWorld'

Extract plain text from HTML:

import { extractTextFromHtml } from 'aeo.js';
const text = extractTextFromHtml('<p>Hello <strong>world</strong></p>');

extractTitle(html) / extractDescription(html)

Section titled “extractTitle(html) / extractDescription(html)”

Extract the title or meta description from an HTML document.

Extract JSON-LD structured data from an HTML document.

Generate JSON-LD schema objects:

import { generateSchemaObjects } from 'aeo.js';
const schemas = generateSchemaObjects(resolvedConfig);

Generate a <script type="application/ld+json"> tag:

import { generateJsonLdScript } from 'aeo.js';
const script = generateJsonLdScript(resolvedConfig);

generateSiteSchemas(config) / generatePageSchemas(config, page)

Section titled “generateSiteSchemas(config) / generatePageSchemas(config, page)”

Generate schemas for the site or individual pages.

Returns an array of MetaTag objects:

import { generateOGTags } from 'aeo.js';
const tags = generateOGTags(config, { pathname: '/', title: 'Home' });
// [{ property: 'og:title', content: 'Home' }, ...]

Returns OG tags as an HTML string.

Audit a site for AEO best practices:

import { auditSite, formatAuditReport, getGrade } from 'aeo.js';
const result = await auditSite('https://mysite.com');
console.log(formatAuditReport(result));
console.log(getGrade(result)); // 'A', 'B', 'C', etc.

Score how likely a page is to be cited by AI:

import { scorePageCitability, formatPageCitability } from 'aeo.js';
const score = await scorePageCitability(url, html);
console.log(formatPageCitability(score));

Score citability across your entire site.

Generate a comprehensive AEO report:

import { generateReport, formatReportMarkdown } from 'aeo.js';
const report = await generateReport(config);
console.log(formatReportMarkdown(report));

All types are exported from the main entry:

import type {
AeoConfig,
ResolvedAeoConfig,
PageEntry,
DocEntry,
AeoManifest,
MarkdownFile,
ManifestEntry,
AIIndexEntry,
FrameworkType,
FrameworkInfo,
AuditResult,
AuditCategory,
AuditIssue,
MetaTag,
PageCitabilityResult,
SiteCitabilityResult,
CitabilityDimension,
ContentHint,
AeoReport,
PlatformHint,
} from 'aeo.js';