TL;DR
Starlight is an Astro-powered documentation framework that creates fast, accessible docs sites from Markdown. Built-in search, i18n, syntax highlighting, and sidebar generation — zero config needed.
What Is Starlight?
Starlight by the Astro team:
- Astro-powered — fast static sites with island architecture
- Markdown/MDX — write docs in Markdown
- Built-in search — Pagefind search, zero config
- i18n — multi-language support built-in
- Auto sidebar — generated from file structure
- Dark/light mode — automatic theme switching
- Free — MIT license
Quick Start
npm create astro@latest -- --template starlight
cd my-docs
npm run dev
Configuration
// astro.config.mjs
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
export default defineConfig({
integrations: [
starlight({
title: "My API Docs",
social: {
github: "https://github.com/myorg/myproject",
},
sidebar: [
{
label: "Getting Started",
items: [
{ label: "Introduction", slug: "getting-started/intro" },
{ label: "Installation", slug: "getting-started/install" },
],
},
{
label: "API Reference",
autogenerate: { directory: "api" },
},
{
label: "Guides",
autogenerate: { directory: "guides" },
},
],
}),
],
});
Write Documentation
---
title: "Getting Started"
description: "Learn how to use our API"
---
## Installation
bash
npm install my-sdk
## Quick Example
javascript
import { Client } from "my-sdk";
const client = new Client({ apiKey: "your-key" });
const result = await client.query("Hello");
console.log(result);
:::note
You need an API key to get started. [Get one here](/auth).
:::
:::tip
Use the `--verbose` flag for detailed logging.
:::
:::caution
Never expose your API key in client-side code.
:::
markdown
Custom Components in MDX
---
title: Interactive Demo
---
import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid>
<Card title="Fast" icon="rocket">
Built on Astro for lightning performance.
</Card>
<Card title="Accessible" icon="accessibility">
WCAG 2.1 AA compliant out of the box.
</Card>
</CardGrid>
i18n (Multi-Language)
starlight({
title: "My Docs",
defaultLocale: "en",
locales: {
en: { label: "English" },
es: { label: "Espanol" },
ja: { label: "Japanese" },
},
})
Starlight vs Docusaurus vs VitePress
| Feature | Starlight | Docusaurus | VitePress |
|---|---|---|---|
| Framework | Astro | React | Vue |
| Build speed | Very fast | Slow | Fast |
| Bundle size | Tiny (0 JS default) | Large | Small |
| Search | Pagefind (built-in) | Algolia (external) | MiniSearch |
| i18n | Built-in | Built-in | Manual |
| MDX | Yes | Yes | No (Vue in MD) |
| Custom components | Astro/React/Vue | React | Vue |
| Performance | 100/100 Lighthouse | 85-95 | 95-100 |
Resources
- Starlight Documentation
- GitHub Repository — 5K+ stars
- Showcase
- Plugins
Documenting your data APIs? My Apify tools extract web data via REST APIs — document them beautifully with Starlight. Questions? Email spinov001@gmail.com
Top comments (0)