Back to Storybook

Before All In Preview

docs/_snippets/before-all-in-preview.md

10.3.62.9 KB
Original Source
js
import { init } from '../project-bootstrap';

export default {
  async beforeAll() {
    await init();
  },
};
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 { init } from '../project-bootstrap';

const preview: Preview = {
  async beforeAll() {
    await init();
  },
};

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

import { init } from '../project-bootstrap';

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

import { init } from '../project-bootstrap';

export default definePreview({
  async beforeAll() {
    await init();
  },
});
ts
import { definePreview } from '@storybook/vue3-vite';

import { init } from '../project-bootstrap';

export default definePreview({
  async beforeAll() {
    await init();
  },
});
<!-- JS snippets still needed while providing both CSF 3 & Next -->
js
import { definePreview } from '@storybook/vue3-vite';

import { init } from '../project-bootstrap';

export default definePreview({
  async beforeAll() {
    await init();
  },
});
ts
import { definePreview } from '@storybook/angular';

import { init } from '../project-bootstrap';

export default definePreview({
  async beforeAll() {
    await init();
  },
});
ts
import { definePreview } from '@storybook/web-components-vite';

import { init } from '../project-bootstrap';

export default definePreview({
  async beforeAll() {
    await init();
  },
});
<!-- JS snippets still needed while providing both CSF 3 & Next -->
js
import { definePreview } from '@storybook/web-components-vite';

import { init } from '../project-bootstrap';

export default definePreview({
  async beforeAll() {
    await init();
  },
});