---
title: "Public API"
description: "Stable public imports exposed by the integrated svedocs framework package."
---

> Documentation Index
> Fetch the complete documentation index at: https://svedocs.pwp.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Public API

Import public APIs from the package paths shown below. Their entry files stay small and stable even when the implementation moves between internal directories.

## Config

```ts
import { defineConfig, loadSvedocsConfig } from 'svedocs/config';
```

Use `defineConfig` for typed configuration and `loadSvedocsConfig` for resolved defaults.

## Vite

```ts
import { svedocs } from 'svedocs/vite';
```

The plugin provides virtual modules, content refresh, MDX/SVX component compilation, injected authoring components, and named layout registration.

Compile-time Markdown hooks live in `svedocs.config.ts`:

```ts
export default defineConfig({
  markdown: {
    remarkPlugins: [],
    rehypePlugins: [],
    shiki: {
      transformers: []
    }
  }
});
```

These hooks run while svedocs builds the page list and renders Svelte-compatible `.svx/.mdx` files. They are not serialized into browser virtual modules.

Virtual modules:

| Module | Value |
| --- | --- |
| `virtual:svedocs/config` | Resolved config |
| `virtual:svedocs/pages` | Complete page list |
| `virtual:svedocs/page-index` | Lightweight page index for client route matching |
| `virtual:svedocs/page-loaders` | Dynamic loaders for full per-page data |
| `virtual:svedocs/tree` | Sidebar tree |
| `virtual:svedocs/search` | Search records |
| `virtual:svedocs/search-loader` | Dynamic loader for client-side search records |
| `virtual:svedocs/component-loaders` | Lazy Svelte content loaders keyed by page ID |
| `virtual:svedocs/layout-loaders` | Lazy layout loaders keyed by layout name |
| `virtual:svedocs/components` | Compiled `.svx/.mdx` components |
| `virtual:svedocs/layouts` | Registered custom layouts |
| `virtual:svedocs/theme-components` | Registered theme component overrides |

`loadSvedocsPage(page, { pages, components, layouts })` loads the current page data, content component, and layout concurrently, returning `{ page, content, layout }`. Use it in universal `+page.ts`; component functions cannot be serialized from `+page.server.ts`. The legacy `components` and `layouts` virtual modules remain available and import every component eagerly.

## Core

```ts
import {
  loadSvedocsContent,
  createPageTree,
  createSearchRecords,
  checkSvedocsContent,
  createAbsoluteUrl,
  createCanonicalUrl,
  createPageCanonicalUrl
} from 'svedocs/core';
import { resolveSvedocsPageRoute, resolveSvedocsHref, loadSvedocsPage, createSvedocsHtmlHandle, getSvedocsDocumentAttributes } from 'svedocs/routes';
```

Core APIs cover content loading, navigation, links, checks, and search records. The browser-safe `svedocs/routes` entry exposes `resolveSvedocsPageRoute` for canonical route loading and default-locale redirects, plus `resolveSvedocsHref` for applying the same locale rules to links.

`createAbsoluteUrl(config, value)` resolves HTTP(S) asset/endpoint URLs without page slash rules. `createCanonicalUrl(config, value)` normalizes same-origin page URLs, retaining queries and removing fragments while preserving external paths. `createPageCanonicalUrl(config, page)` uses the explicit canonical or route, returning undefined without a site URL or explicit canonical.

`createSvedocsHtmlHandle({ config, pages })` is a SvelteKit server Handle that sets `<html lang dir>` during SSR and prerendering. `getSvedocsDocumentAttributes({ config, pages }, pathname)` returns `{ lang, dir }` for custom app shells.

## Theme

```ts
import {
  DocsApp,
  RootLayout,
  Seo,
  LayoutShell,
  DocsLayout,
  DocsShell,
  DocPage,
  Article,
  PageLayout,
  PageShell,
  ErrorPage,
  RenderError,
  Navbar,
  TableOfContents,
  Footer,
  PageTools,
  HomePage,
  ThemeInit,
  FormField,
  Input,
  Select,
  Textarea,
  Checkbox,
  Button,
  LocalizedLink,
  Integrations,
  GoogleAd,
  GoogleAdsConversion
} from 'svedocs/theme';
import 'svedocs/theme/styles.css';
import 'svedocs/theme/base.css';
import { createSearchController, createAskAiController } from 'svedocs/theme/headless';
import type { SvedocsThemeComponentMap, SvedocsNavbarProps, SvedocsSeoProps } from 'svedocs/theme/types';
```

Use `DocsApp` for the complete route shell or compose lower-level components for custom apps.
Use the form controls in custom pages and layouts when you want project UI to inherit the default svedocs theme.
Use `themeComponents` plus the headless controllers when building a fully custom theme without the default stylesheet. See [Components](/docs/reference/theme-components) for the per-component props.

## Cloudflare

```ts
import { createCloudflarePreset, createWranglerJsonc, createCloudflareEnvDts } from 'svedocs/cloudflare';
```

These helpers align SvelteKit build modes, `wrangler.toml` or `wrangler.jsonc`, and platform binding types.

## Search and AI

```ts
import { createConfiguredSearchResponse, createSearchResponse, searchRecords } from 'svedocs/search';
import { createConfiguredAskResponse, createAskResponse, createMemoryRateLimiter } from 'svedocs/ai';
```

Search and Ask AI support local, Algolia, Typesense, Cloudflare, and OpenAI-compatible services. Local search can filter by locale and content kind.

Generated route handlers should use the configured response utilities. Import lower-level providers such as `createAlgoliaSearchProvider`, `createTypesenseSearchProvider`, `createCloudflareAiSearchProvider`, `createWorkersAiProvider`, or `createOpenAiCompatibleProvider` only when you need custom routing or service selection.

## Service integrations

```ts
import {
  createIntegrationAssets,
  createIndexNowPayloads,
  submitIndexNow,
  trackGoogleAdsConversion
} from 'svedocs/integrations';
import type { IndexNowPayload, IndexNowResult, SvedocsIntegrationsConfig } from 'svedocs/integrations';
```

| API | Behavior |
| --- | --- |
| `createIntegrationAssets(config)` | Returns a filename-to-content record for the IndexNow key file and AdSense `ads.txt`, without reading or writing files. The Vite plugin handles emission and preserves a user-owned `ads.txt`. |
| `createIndexNowPayloads(config, pages)` | Returns `IndexNowPayload[]` containing discoverable same-origin canonical URLs, deduplicated and split into batches of at most 10,000. Throws if IndexNow is disabled. Does not make requests. |
| `submitIndexNow(config, pages, options?)` | Verifies the deployed key file, submits each batch, and returns `Promise<IndexNowResult>` with `submitted`, `batches`, and `statuses`. Non-200/202 submission responses throw. `options.fetch` supplies a request implementation; `verifyKey: false` skips the deployment check. Call from deployment tooling after publishing. |
| `trackGoogleAdsConversion(integrations, name, development?, transactionId?)` | Sends a named conversion from `config.integrations.googleAds.conversions`. Pass `config.integrations` and SvelteKit's `dev` flag. Respects disabled providers and Do Not Track; does nothing during SSR. |

The module also exports `SvedocsAdSlot`, `SvedocsGoogleAdsConversion`, and `SvedocsResolvedIntegrations` types. Input and resolved integration types are available from `svedocs/config` as well.

For configuration-only setup and automatic pageviews, use the [integration guide](/docs/integrations/analytics-ads-indexnow). `Integrations`, `GoogleAd`, and `GoogleAdsConversion` are Svelte components from `svedocs/theme`; their props are documented in [Theme components](/docs/reference/theme-components).

## OG

```ts
import {
  createPageMetadata,
  createPageAlternates,
  createSitemapXml,
  createSitemapResponse,
  createRobotsTxt,
  createRssXml,
  createRssResponse,
  createPageOgImageResponse,
  createOgImageInput,
  createOgImage
} from 'svedocs/og';
```

Use these APIs for custom route handlers, custom layouts, and build-time OG generation.

## Virtual module types

Add `/// <reference types="svedocs/virtual" />` to `src/app.d.ts` to type the `virtual:svedocs/*` imports. This export contains TypeScript declarations; it is not a runtime module.

Source: https://svedocs.pwp.sh/docs/reference/api
