-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Docs: Fix broken links in framework pages #33369
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,4 +60,4 @@ function HelloWorld() { | |
| } | ||
|
|
||
| export default HelloWorld; | ||
| ``` | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| ```shell renderer="react-native-web" language="js" packageManager="npm" | ||
| ```shell renderer="common" language="sh" packageManager="npm" | ||
| npm install --save-dev @storybook/react-native-web-vite vite | ||
| ``` | ||
|
|
||
| ```shell renderer="react-native-web" language="js" packageManager="pnpm" | ||
| ```shell renderer="common" language="sh" packageManager="pnpm" | ||
| pnpm add --save-dev @storybook/react-native-web-vite vite | ||
| ``` | ||
|
|
||
| ```shell renderer="react-native-web" language="js" packageManager="yarn" | ||
| ```shell renderer="common" language="sh" packageManager="yarn" | ||
| yarn add --dev @storybook/react-native-web-vite vite | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,16 +6,15 @@ sidebar: | |
| title: Next.js (Vite) | ||
| --- | ||
|
|
||
| Storybook for Next.js (Vite) is the **recommended** [framework](../../contribute/framework.mdx) for developing and testing UI components in isolation for [Next.js](https://nextjs.org/) applications. It uses [Vite](https://vitejs.dev/) for faster builds, better performance and [Storybook Testing](https://storybook.js.org/docs/writing-tests) support. | ||
| Storybook for Next.js (Vite) is the **recommended** [framework](../../contribute/framework.mdx) for developing and testing UI components in isolation for [Next.js](https://nextjs.org/) applications. It uses [Vite](https://vitejs.dev/) for faster builds, better performance and [Storybook Testing](../../writing-tests/index.mdx) support. | ||
|
|
||
| ## Install | ||
|
|
||
| To install Storybook in an existing Next.js project, run this command in your project's root directory: | ||
|
|
||
| <CodeSnippets path="create-command.md" variant="new-users" copyEvent="CreateCommandCopy" /> | ||
|
|
||
| You can then get started [writing stories](/docs/get-started/whats-a-story/), [running tests](/docs/writing-tests/) and [documenting your components](/docs/writing-docs/). For more control over the installation process, refer to the [installation guide](/docs/install/). | ||
|
|
||
| You can then get started [writing stories](../whats-a-story.mdx), [running tests](../../writing-tests/index.mdx) and [documenting your components](../../writing-docs/index.mdx). For more control over the installation process, refer to the [installation guide](../install.mdx). | ||
|
|
||
| ### Requirements | ||
|
|
||
|
|
@@ -56,9 +55,6 @@ To build Storybook, run: | |
|
|
||
| You will find the output in the configured `outputDir` (default is `storybook-static`). | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ## Configure | ||
|
|
||
| Storybook for Next.js with Vite supports many Next.js features including: | ||
|
|
@@ -410,54 +406,60 @@ const preview: Preview = { | |
|
|
||
| [`next/head`](https://nextjs.org/docs/pages/api-reference/components/head) is supported out of the box. You can use it in your stories like you would in your Next.js application. Please keep in mind, that the Head `children` are placed into the head element of the iframe that Storybook uses to render your stories. | ||
|
|
||
| ### Styling | ||
|
|
||
| #### Sass/Scss | ||
| ## Next.js styling | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea behind the change of headers was to have all configuration sections under "Configure". The |
||
|
|
||
| [Global Sass/Scss stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are supported without any additional configuration as well. Just import them into [`.storybook/preview.js|ts`](../../configure/index.mdx#configure-story-rendering) | ||
| ### Sass/Scss | ||
|
|
||
| ```js title=".storybook/preview.js|ts" | ||
| import '../styles/globals.scss'; | ||
| ``` | ||
| [Global Sass/SCSS stylesheets](https://nextjs.org/docs/pages/building-your-application/styling/sass) are also supported without any additional configuration. Just import them into [the preview config file](../../configure/index.mdx#configure-story-rendering). | ||
|
|
||
| This will automatically include any of your [custom Sass configurations](https://nextjs.org/docs/pages/building-your-application/styling/sass#customizing-sass-options) in your `next.config.js` file. | ||
| {/* prettier-ignore-start */} | ||
|
|
||
| ```js title="next.config.js" | ||
| import * as path from 'path'; | ||
| <CodeSnippets path="nextjs-styling-sass-preview.md" /> | ||
|
|
||
| export default { | ||
| // Any options here are included in Sass compilation for your stories | ||
| sassOptions: { | ||
| includePaths: [path.join(process.cwd(), 'styles')], | ||
| }, | ||
| }; | ||
| ``` | ||
| {/* prettier-ignore-end */} | ||
|
|
||
| This will automatically include any of your [custom Sass configurations](https://nextjs.org/docs/pages/building-your-application/styling/sass#customizing-sass-options) in your Next.js config file. | ||
|
|
||
| #### CSS/Sass/Scss Modules | ||
| {/* prettier-ignore-start */} | ||
|
|
||
| <CodeSnippets path="nextjs-styling-sass-config.md" /> | ||
|
|
||
| {/* prettier-ignore-end */} | ||
|
|
||
| ### CSS/Sass/Scss Modules | ||
|
|
||
| [CSS modules](https://nextjs.org/docs/pages/building-your-application/styling/css-modules) work as expected. | ||
|
|
||
| ```jsx title="src/components/Button.jsx" | ||
| // This import will work in Storybook | ||
| import styles from './Button.module.css'; | ||
| // Sass/Scss is also supported | ||
| // import styles from './Button.module.scss' | ||
| // import styles from './Button.module.sass' | ||
| {/* prettier-ignore-start */} | ||
|
|
||
| export function Button() { | ||
| return ( | ||
| <button type="button" className={styles.error}> | ||
| Destroy | ||
| </button> | ||
| ); | ||
| } | ||
| ``` | ||
| <CodeSnippets path="nextjs-styling-css-modules.md" /> | ||
|
|
||
| {/* prettier-ignore-end */} | ||
|
|
||
| #### PostCSS | ||
| ### Styled JSX | ||
|
|
||
| Next.js lets you [customize PostCSS config](https://nextjs.org/docs/pages/building-your-application/configuring/post-css). Thus this framework will automatically handle your PostCSS config for you. | ||
| The built-in CSS-in-JS solution for Next.js is [styled-jsx](https://nextjs.org/docs/pages/building-your-application/styling/css-in-js), and this framework supports that out of the box, too, with zero config. | ||
|
|
||
| {/* prettier-ignore-start */} | ||
|
|
||
| <CodeSnippets path="nextjs-styling-styled-jsx-component.md" /> | ||
|
|
||
| {/* prettier-ignore-end */} | ||
|
|
||
| ### Tailwind | ||
|
|
||
| This allows for cool things like zero-config Tailwind! (See [Next.js' example](https://github.com/vercel/next.js/tree/canary/packages/create-next-app/templates/default-tw)) | ||
| Tailwind in Next.js [is supported via PostCSS](https://nextjs.org/docs/app/getting-started/css#tailwind-css). Storybook will automatically handle the PostCSS config for you, including any custom PostCSS configuration, so that you can import your global CSS directly into [the preview config file](../../configure/index.mdx#configure-story-rendering): | ||
|
|
||
| {/* prettier-ignore-start */} | ||
|
|
||
| <CodeSnippets path="nextjs-styling-tailwind.md" /> | ||
|
|
||
| {/* prettier-ignore-end */} | ||
|
|
||
| ### PostCSS | ||
|
|
||
| Next.js lets you [customize PostCSS config](https://nextjs.org/docs/pages/building-your-application/configuring/post-css). Thus this framework will automatically handle your PostCSS config for you. | ||
|
|
||
| ### Imports | ||
| #### Absolute imports | ||
|
|
@@ -638,7 +640,7 @@ To enable this set the `experimentalRSC` feature flag in your `.storybook/main.j | |
|
|
||
| Setting this flag automatically wraps your story in a [Suspense](https://react.dev/reference/react/Suspense) wrapper, which is able to render asynchronous components in NextJS's version of React. | ||
|
|
||
| If this wrapper causes problems in any of your existing stories, you can selectively disable it using the `react.rsc` [parameter](https://storybook.js.org/docs/writing-stories/parameters) at the global/component/story level: | ||
| If this wrapper causes problems in any of your existing stories, you can selectively disable it using the `react.rsc` [parameter](../../writing-stories/parameters.mdx) at the global/component/story level: | ||
|
|
||
| {/* prettier-ignore-start */} | ||
|
|
||
|
|
@@ -654,7 +656,6 @@ In the future we will provide better mocking support in Storybook and support fo | |
|
|
||
| ## FAQ | ||
|
|
||
|
|
||
| ### How do I migrate from the `nextjs` (Webpack 5) addon? | ||
|
|
||
| #### Automatic migration | ||
|
|
@@ -673,7 +674,7 @@ This automigration tool performs the following actions: | |
|
|
||
| <Callout variant="info"> | ||
|
|
||
| If your project has custom Webpack configurations in `.storybook/main.js|ts` (via `webpackFinal`), you'll need to migrate those to Vite configuration (via `viteFinal`) after running this automigration. See the [Vite builder documentation](../builders/vite.mdx#migrating-from-webpack) for more information. | ||
| If your project has custom Webpack configurations in `.storybook/main.js|ts` (via `webpackFinal`), you'll need to migrate those to Vite configuration (via `viteFinal`) after running this automigration. See the [Vite builder documentation](../../builders/vite.mdx#migrating-from-webpack) for more information. | ||
|
|
||
| </Callout> | ||
|
|
||
|
|
@@ -711,8 +712,6 @@ Finally, if you were using Storybook plugins to integrate with Next.js, those ar | |
|
|
||
| {/* prettier-ignore-end */} | ||
|
|
||
|
|
||
|
|
||
| ### Stories for pages/components which fetch data | ||
|
|
||
| Next.js pages can fetch data directly within server components in the `app` directory, which often include module imports that only run in a node environment. This does not (currently) work within Storybook, because if you import from a Next.js page file containing those node module imports in your stories, your Storybook's Vite build will crash because those modules will not run in a browser. To get around this, you can extract the component in your page file into a separate file and import that pure component in your stories. Or, if that's not feasible for some reason, you can [configure Vite to handle those modules](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude) in your Storybook's [`viteFinal` configuration](../../builders/vite.mdx#configuration). | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did find it harder for the 404 detection tool I tried to work with relative paths. I'm also myself not so keen to use relative paths because when we move a file around:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hear you and we need to invest in a proper way to vet the links and avoid situations like and safeguard us.