If a story component imports '$app/navigation'
, SvelteKit emits this error when rendering the story:
Cannot read properties of undefined (reading 'disable_scroll_handling')
TypeError: Cannot read properties of undefined (reading 'disable_scroll_handling')
at http://localhost:6006/node_modules/@sveltejs/kit/src/runtime/app/navigation.js?v=b4aad7c7:14:11
-
Scaffold new SvelteKit project:
npm create svelte@latest my-app cd my-app npm install
-
Add Storybook:
npx storybook@next init
-
Edit
src/stories/Button.svelte
to import'$app/navigation'
:<script lang="ts"> import { goto } from '$app/navigation'; </script>
-
Run Storybook:
npm run storybook
-
Open the
Button
story in the browser.