Add the versioned script before the closing </body> tag, after the container,
so the container exists when your code creates the view. A fixed version keeps
the deployed SDK the same until you choose to update it.
<divid="storyteller-stories-row"style="height: 200px"></div><scriptsrc="https://content.usestoryteller.com/javascript-sdk/11.0.0/dist/storyteller.min.js"></script><script>asyncfunctionstartStoryteller(){awaitStoryteller.sharedInstance.initialize('demo-api-key');newStoryteller.StorytellerStoriesRowView('storyteller-stories-row');}startStoryteller().catch((error)=>{console.error('Storyteller could not start.',error);});</script>
The script adds its styles to the page. Storyteller becomes available on
window after the script loads.
Replace demo-api-key with your API key. To show Stories from specific
Categories, pass their IDs as the second argument:
Earlier guides used a /javascript-sdk/latest/ URL. That path does not
serve production releases. Use a fixed version URL, such as the 11.0.0
URL above.
The script downloads the Story player, Clips player, Poll, Quiz, and caption
code the first time a page needs it. These files load from the same directory
as storyteller.min.js, for example
https://content.usestoryteller.com/javascript-sdk/11.0.0/dist/. Their names
look like storyteller.story-player.<hash>.min.js.
The Storyteller CDN serves all of these files. To host the SDK on your own
server:
Copy every file in the version's dist directory to one directory.
Keep the file names.
Load storyteller.min.js from its own <script> tag. Don't bundle, rename,
or inline it.
If your site uses a Content Security Policy (CSP), allow scripts from the SDK
directory in script-src, for example
https://content.usestoryteller.com/javascript-sdk/11.0.0/dist/. The SDK adds
its files to the page as <script> elements without a nonce. If your policy
allows scripts only by nonce or hash, also add 'strict-dynamic' or the SDK
directory.
The Story player also loads the AMP Story player script from
https://stories.usestoryteller.com/amp/.
A horizontal row of Story tiles appears. If the container stays empty, open the
browser console and look for a failed script request or an initialization
error. See Troubleshoot an integration.
{"slug": "getting-started-script", "page_title": "Install with a Script Tag", "page_url": "getting-started/script/", "canonical_url": "/web/getting-started/script/", "markdown": "# Install with a script tag\n\nLoad the SDK from the Storyteller CDN when your site has no JavaScript build\nstep.\n\n## Add the SDK\n\nAdd the versioned script before the closing `<\/body>` tag, after the container,\nso the container exists when your code creates the view. A fixed version keeps\nthe deployed SDK the same until you choose to update it.\n\n```html\n<div id=\"storyteller-stories-row\" style=\"height: 200px\"><\/div>\n\n<script src=\"https://content.usestoryteller.com/javascript-sdk/11.0.0/dist/storyteller.min.js\"><\/script>\n<script>\n async function startStoryteller() {\n await Storyteller.sharedInstance.initialize('demo-api-key');\n\n new Storyteller.StorytellerStoriesRowView(\n 'storyteller-stories-row'\n );\n }\n\n startStoryteller().catch((error) => {\n console.error('Storyteller could not start.', error);\n });\n<\/script>\n```\n\nThe script adds its styles to the page. `Storyteller` becomes available on\n`window` after the script loads.\n\nReplace `demo-api-key` with your API key. To show Stories from specific\nCategories, pass their IDs as the second argument:\n\n```javascript\nnew Storyteller.StorytellerStoriesRowView('storyteller-stories-row', [\n 'category-id',\n]);\n```\n\n!!! note\n\n Earlier guides used a `/javascript-sdk/latest/` URL. That path does not\n serve production releases. Use a fixed version URL, such as the `11.0.0`\n URL above.\n\n## Host the SDK files {#host-the-sdk-files}\n\nThe script downloads the Story player, Clips player, Poll, Quiz, and caption\ncode the first time a page needs it. These files load from the same directory\nas `storyteller.min.js`, for example\n`https://content.usestoryteller.com/javascript-sdk/11.0.0/dist/`. Their names\nlook like `storyteller.story-player.<hash>.min.js`.\n\nThe Storyteller CDN serves all of these files. To host the SDK on your own\nserver:\n\n- Copy every file in the version's `dist` directory to one directory.\n- Keep the file names.\n- Load `storyteller.min.js` from its own `<script>` tag. Don't bundle, rename,\n or inline it.\n\n### Content Security Policy {#content-security-policy}\n\nIf your site uses a Content Security Policy (CSP), allow scripts from the SDK\ndirectory in `script-src`, for example\n`https://content.usestoryteller.com/javascript-sdk/11.0.0/dist/`. The SDK adds\nits files to the page as `<script>` elements without a nonce. If your policy\nallows scripts only by nonce or hash, also add `'strict-dynamic'` or the SDK\ndirectory.\n\nThe Story player also loads the AMP Story player script from\n`https://stories.usestoryteller.com/amp/`.\n\n## Check the result\n\nA horizontal row of Story tiles appears. If the container stays empty, open the\nbrowser console and look for a failed script request or an initialization\nerror. See [Troubleshoot an integration](troubleshooting.md).\n\nThe Storyteller Web Showcase builds the same versioned CDN URL in\n[`buildVersionedDemoSdkScriptUrl`](https://github.com/getstoryteller/storyteller-showcase-web/blob/11.0.0/nextjs/src/helpers/sdkVersionRouting.ts#L238).\n\n## Next steps\n\n- [Show your first Story row](../Quickstart.md)\n- [Choose a view](../views/index.md)\n- [Identify and personalize users](../Users.md)\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}