question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use next-i18next with storybook?

See original GitHub issue

I would like to integrate next-i18next with our storybook that is used in our nextjs app.

I cannot use appWithTranslation wrapper` as the storybook wrapper is just a normal react component and not App (ts fails as well)

One story is defined for example as Banana.stories.tsx

storiesOf('Banana', module).add('default', () => {
    return (
        <StoryWrapper>
            <BananaForm {...props} />
        </StoryWrapper>
    );
});

and StoryWrapper.tsx is just adding the styled components context to all the stories

    <ThemeProvider theme={getTheme(props.theme)}>
        <Fragment>
            {props.children}
        </Fragment>
    </ThemeProvider>

If BananaForm contains useTranslation hook storybook will crash and that brings me to the question posted here.

How to integrate this library with storybook ?

Would be really awesome developer experience to use same translations as the real project

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
isaachinmancommented, May 30, 2022

Duplicate of #1713.

1reaction
zaratancommented, Nov 10, 2022

If anyone is using webpack 5 with storybook @thebinaryfelix solution almost worked for me.

The only difference was in .storybook/main.js as webpack config do not support {node: { fs: 'empty' }} anymore.

module.exports = {
  // …
  webpackFinal: async (config) => {
    config.resolve ||= {}
    config.resolve.fallback ||= {}
    config.resolve.fallback.fs =  false;

    return config
  },
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using next-i18next in Storybook - gists · GitHub
next -i18next is built to work server-side as well as client-side. Storybook doesn't support server-side rendering so there's nowhere to add the next-i18next...
Read more >
Using next-i18next in Storybook - DEV Community ‍ ‍
next -i18next is built to work server-side as well as client-side. Storybook doesn't support server-side rendering so there's nowhere to add ...
Read more >
Storybook react-i18next addon
Create a file in your .storybook folder called i18next.js (or whatever you like). In this file, copy and paste the below code and...
Read more >
Localize React with i18next in Storybook - YouTube
Claim free Storybook hosting at https://www.chromatic.com/! ... website content using Next.js internationalization and next - i18next.
Read more >
Configuring Storybook for Next.Js, I18n, SCSS & TypeScript
This will take care of the initial setup. It'll: add the packages; add the package scripts; add the config files under .storybook ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found