Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use Composable #482

Closed
y-negishi opened this issue Mar 15, 2024 · 1 comment
Closed

Cannot use Composable #482

y-negishi opened this issue Mar 15, 2024 · 1 comment

Comments

@y-negishi
Copy link

If I build a story that usesRuntimeConfig with <script setup> and then serve it, I get an error.

[nuxt] instance unavailable

image

Code

export function useMyComposable() {
  // Because your composable is called in the right place in the lifecycle,
  // useRuntimeConfig will also work
  const config = useRuntimeConfig();
  // console.log('useMyComposable config', config)
  return { config };
}
<script setup>
const { config } = useMyComposable();
</script>

<template>
  <h1>Welcome Nuxt to Storybook</h1>
  <p>{{ config }}</p>
</template>
import type { Meta, StoryObj } from '@storybook/vue3'
import MyNuxtWelcome from './MyWelcome.vue'

const meta = {
  title: 'Example/NuxtWelcome',
  component: MyNuxtWelcome,
  tags: ['autodocs'],

} satisfies Meta<typeof MyNuxtWelcome>

export default meta
type Story = StoryObj<typeof meta>

export const NuxtWelcomeStory: Story = {
  args: {},
}

Environment

"nuxt": "3.9.1",
"storybook": "7.6.7",
"@nuxtjs/storybook": "7.0.0",
"@storybook-vue/nuxt": "0.2.1",
"@storybook/builder-vite": "7.6.7",
"@storybook/vue3": "7.6.7",
"@storybook/vue3-vite": "7.6.7",

Stackblitz

https://stackblitz.com/edit/storybook-vuetify-nuxt-xhunbk?file=package.json

@tobiasdiez
Copy link
Collaborator

Duplicate of storybook-vue/storybook-nuxt#97.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants