Next.js, Storybook, images from external source #136
-
When I use Next.js The second problem is that the images don't get displayed in Storybook. I get this error message:
Does storybook has its own |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi Andreas, First question Regarding your first question, I see two approaches: a) Writing a Next.js API Route providing a proxy feature like
This example might push you into the right direction: b) Trying out a new experimental (!) Next.js config. I haven't used this before, but you could try to set https://nextjs.org/docs/api-reference/next/image#remote-patterns Second question: If you want to use Next.js components outside of a Next.js application (like Storybook), you need to write a mock in some situations. With images, you need to disable the optimization. Here is a good blog post with a solution: https://storybook.js.org/blog/get-started-with-storybook-and-next-js/ The interesting part starts at "2. Use the unoptimized prop for Next.js Images in Storybook" |
Beta Was this translation helpful? Give feedback.
Hi Andreas,
First question
Regarding your first question, I see two approaches:
a) Writing a Next.js API Route providing a proxy feature like
res.cloudinary.com
response
back to the clientThis example might push you into the right direction:
https://maxschmitt.me/posts/next-js-api-proxy/
b) Trying out a new experimental (!) Next.js config. I haven't used this before, but you could try to set
**
forhostname
andpathname
.https://nextjs.org/docs/api-reference/next/image#remote-patterns
Second question:
If you want to use Next.js components outside of a Next.js application (like Storybook), you need to write a mock in …