# ember-cli-storybook
**Repository Path**: mirrors_hashicorp/ember-cli-storybook
## Basic Information
- **Project Name**: ember-cli-storybook
- **Description**: 📒 Ember storybook adapter
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2022-03-26
- **Last Updated**: 2026-05-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# ember-cli-storybook
> 📒 Ember storybook adapter
# Compatibility
* Ember.js v3.16 or above
* Ember CLI v2.13 or above
* Node.js v16 or above
# Installation
```shell
ember install @storybook/ember-cli-storybook
```
# Usage
This will be triggered automatically as a post build action when running `ember build`
> package.json options (defaults)
```json
"storybook": {
"ignoreTestFiles": true,
"config": {}
}
```
> ember-cli-build options (defaults)
```json
"ember-cli-storybook": {
"componentFilePathPatterns": [],
"enableAddonDocsIntegration": true, // enables yuidoc generation
}
```
## Config
The config object represents anything that could be parsed from an `index.html` file. This must be in the format as below:
```json
{
"meta": [{
"attributes": ["name", "content"]
}, {
"attributes": ["name", "content"]
}, {
"attributes": ["name", "content", "id"]
}],
"link": [{
"selector": "link",
"attributes": ["rel", "href"]
}],
"script": [{
"selector": "script",
"attributes": ["src"]
}]
}
```
So in order to add a script tag to the generated `preview-head.html` a potential config would look like:
```json
"storybook": {
"config": {
"script": {
"src": "./assets/foo.js"
}
}
}
```
> It is important to note that storybook will by default serve any files out of the `public` folder. If you have custom files you would like to serve they need to exist there.
# Troubleshooting
### Components that need routing for query parameters
The Storybook integration for Ember [renders stories into a custom component](https://github.com/storybookjs/storybook/blob/27210146d605e5a8fc630c0a70b7743be61d8f3f/app/ember/src/client/preview/render.js#L31-L34) in a router-less environment. This works for many situations but is insufficient when you have a story that requires query parameters, like a component that persists sorting or pagination information to the URL. There’s no official way to accomplish this as of yet, but you can work around it by dynamically adding a route, visiting it using the [private `startRouting` API](https://api.emberjs.com/ember/3.14/classes/EmberRouter/methods/startRouting?anchor=startRouting&show=inherited%2Cprivate), and injecting a pseudo-controller, such as in this utility function:
```javascript
function injectRoutedController(controllerClass) {
return on('init', function() {
let container = getOwner(this);
container.register('controller:storybook', controllerClass);
let routerFactory = container.factoryFor('router:main');
routerFactory.class.map(function() {
this.route('storybook');
});
let router = container.lookup('router:main');
router.initialURL = 'storybook';
router.startRouting(true);
this.set('controller', container.lookup('controller:storybook'));
});
}
```
Then you can use it in a story like this:
```javascript
export let SortableColumns = () => {
return {
template: hbs`
{{row.model.name}}
{{row.model.lang}}