You can use environment variables in Storybook to change its behaviour in different “modes”.
If you supply an environment variable prefixed with
STORYBOOK_, it will be available in
You can also access these variables in your custom
<body> using the substitution
%STORYBOOK_X%, for example:
%STORYBOOK_THEME% will become
<link rel="stylesheet" href="%STORYBOOK_STYLE_URL%" />
You can also use
.env files to change Storybook's behavior in different modes. For example, if you add a
.env file to your project with the following:
Then you can access this environment variable anywhere, even within your stories:
.env.productionto apply different values to your environment variables.
You can also pass these environment variables when you are building your Storybook with
Then they'll be hard coded to the static version of your Storybook.
Storybook allows you to choose the browser you want to preview your stories. Either through an
.env file entry or directly in your
The table below lists the available options: