Skip to content

Getting started with Histoire ​

Overview ​

Histoire is the French word for "Story" and is pronounced /is.twaʁ/, like "is·twar"

Use Histoire to develop and document Svelte components in a component book. Check the Node.js and Vite requirements, then set up the Svelte plugin in your project.

Learn what you can build with Histoire.

Sponsors ​

Our sponsors support Histoire's open-source development.

See our sponsors »

Svelte 5 support 1.0-beta.2+ ​

Svelte 5 is supported alongside Svelte 4. Both use @histoire/plugin-svelte and the same story format.

SvelteKit 3 support 1.0-beta.2+ ​

SvelteKit 2 and 3 projects use @histoire/plugin-svelte alongside their existing SvelteKit Vite setup. Register HstSvelte() as shown below.

In a fresh SvelteKit checkout, run pnpm exec svelte-kit sync before starting Histoire to generate SvelteKit's project files.

Installation ​

Install the histoire and @histoire/plugin-svelte packages into your project:

shell
pnpm i -D histoire @histoire/plugin-svelte
# OR
npm i -D histoire @histoire/plugin-svelte
# OR
yarn add -D histoire @histoire/plugin-svelte

Create an histoire.config.js or histoire.config.ts file in your project root to enable the Svelte plugin:

ts
import { HstSvelte } from '@histoire/plugin-svelte'
import { defineConfig } from 'histoire'

export default defineConfig({
  plugins: [
    HstSvelte(),
  ],
})

Write your first story ​

Create Button.story.svelte in your project.

svelte
<script>
  export let Hst
</script>

<Hst.Story title="Button">
  <button>Continue</button>
</Hst.Story>

Command Line Interface ​

Add these scripts to package.json.

json
{
  "scripts": {
    "story:dev": "histoire dev",
    "story:build": "histoire build",
    "story:preview": "histoire preview"
  }
}

Run pnpm story:dev (or npm run story:dev) and open the printed address. Select Button in Stories. Changes to the story appear as you edit.

Use story:build to build a static book and story:preview to serve it locally. Run npx histoire --help for CLI options such as --port.

Configuration ​

See configuring Histoire for shared setup, Vite overrides, and theming.

Community ​

If you have questions or need help, reach out to the community at Discord and GitHub Discussions.

Released under the MIT License.