feat: add next/link mock with useLinkStatus#121
Merged
valentinpalkovic merged 2 commits intoMay 19, 2026
Conversation
Merged
8 tasks
Verifies the new useLinkStatus mock: DefaultLinkStatus asserts the
default non-pending ("Idle") state, and PendingLinkStatus overrides the
mock via @storybook/nextjs-vite/link.mock to assert the pending
("Pending") state. Mirrors the equivalent @storybook/nextjs template
stories.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
valentinpalkovic
approved these changes
May 19, 2026
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a Storybook-friendly mock for
next/link, including theuseLinkStatushook introduced in Next 15.3. Previously,@storybook/nextjs-vitehad no Link mock at all — stories usingnext/link(and especiallyuseLinkStatus) would fail with:What changed
src/plugins/next-mocks/alias/link/index.tsx— a Storybook-friendlyLinkmock (records click actions viafn()) plus a mockableuseLinkStatushook that defaults to{ pending: false }.src/plugins/next-mocks/plugin.tsfor:next/link@storybook/nextjs/link.mock@storybook/nextjs-vite/link.mock@storybook/experimental-nextjs-vite/link.mocktsup.config.ts../browser/mocks/linkand./node/mocks/linkinpackage.json.This mirrors how
navigation,router,headers, andcacheare wired today.Context
Companion PRs in the main Storybook repo:
useLinkStatusfix for@storybook/nextjsby @philwolstenholme@storybook/nextjs-vite@valentinpalkovic asked me to bring the LinkMock over here since the equivalent didn't exist for
nextjs-vite. See the conversation on #34593 for context.Test plan
pnpm buildsucceeds and emits:dist/plugins/next-mocks/alias/link/index.jsdist/plugins/next-mocks/alias/link/index.cjsdist/plugins/next-mocks/alias/link/index.d.tsdist/plugins/next-mocks/alias/link/index.d.ctspnpm check(biome) passes cleanuseLinkStatusfromnext/linkno longer throws and thatuseLinkStatuscan be overridden viaparameters.nextjs.navigation/ mock module to return{ pending: true }.