Back to Storybook

Initialize Library In Preview

docs/_snippets/initialize-library-in-preview.md

10.3.62.1 KB
Original Source
ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { Preview } from '@storybook/your-framework';

import { initialize } from '../lib/your-library';

initialize();

const preview: Preview = {
  // ...
};

export default preview;
js
import { initialize } from '../lib/your-library';

initialize();

export default {
  // ...
};
ts
// Replace your-framework with the framework you are using, e.g. nextjs, nextjs-vite, react-vite, etc.
import { definePreview } from '@storybook/your-framework';

import { initialize } from '../lib/your-library';

initialize();

const preview = definePreview({
  // ...
});

export default preview;
<!-- JS snippets still needed while providing both CSF 3 & Next -->
js
// Replace your-framework with the framework you are using, e.g. nextjs, nextjs-vite, react-vite, etc.
import { definePreview } from '@storybook/your-framework';

import { initialize } from '../lib/your-library';

initialize();

const preview = definePreview({
  // ...
});

export default preview;
ts
import { definePreview } from '@storybook/web-components-vite';

import { initialize } from '../lib/your-library';

initialize();

const preview = definePreview({
  // ...
});

export default preview;
<!-- JS snippets still needed while providing both CSF 3 & Next -->
js
import { definePreview } from '@storybook/web-components-vite';

import { initialize } from '../lib/your-library';

initialize();

const preview = definePreview({
  // ...
});

export default preview;