Skip to content

feat(nuxt): add Nuxt 4 support#831

Open
waldemarennsaed wants to merge 2 commits intohistoire-dev:mainfrom
waldemarennsaed:feat/nuxt-4-support
Open

feat(nuxt): add Nuxt 4 support#831
waldemarennsaed wants to merge 2 commits intohistoire-dev:mainfrom
waldemarennsaed:feat/nuxt-4-support

Conversation

@waldemarennsaed
Copy link
Copy Markdown
Contributor

Summary

  • Widen @histoire/plugin-nuxt peer dependency to accept nuxt ^4.0.0 alongside ^3.0.0-rc.11
  • Widen @nuxt/kit and @nuxt/schema dependency ranges to include ^4.0.0
  • Update plugin description to be version-agnostic
  • Restore examples/nuxt3/ and test-nuxt3.yml CI workflow to ensure dual-version compatibility

Closes #810

Test plan

  • pnpm install succeeds without Nuxt peer dependency warnings
  • pnpm run build passes
  • pnpm run lint passes (0 errors)
  • Nuxt 4 example Cypress tests pass (6/6)
  • Nuxt 3 example Cypress tests pass (6/6)

Update @histoire/plugin-nuxt to officially support Nuxt 4 by widening
the nuxt peer dependency range and @nuxt/kit dependency range to
include ^4.0.0.

Closes histoire-dev#810
Re-add examples/nuxt3 alongside the existing Nuxt 4 example to ensure
dual-version compatibility. Restore the test-nuxt3.yml CI workflow.
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@codesandbox
Copy link
Copy Markdown

codesandbox bot commented Mar 30, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for histoire-examples-svelte3 failed.

Name Link
🔨 Latest commit 72954c5
🔍 Latest deploy log https://app.netlify.com/projects/histoire-examples-svelte3/deploys/69ca1c15dfc72d00089f66bf

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for histoire-controls failed.

Name Link
🔨 Latest commit 72954c5
🔍 Latest deploy log https://app.netlify.com/projects/histoire-controls/deploys/69ca1c152284620008bc0996

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for histoire-examples-vue3 failed.

Name Link
🔨 Latest commit 72954c5
🔍 Latest deploy log https://app.netlify.com/projects/histoire-examples-vue3/deploys/69ca1c1580f14a00080f5b2b

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for histoire-site ready!

Name Link
🔨 Latest commit 72954c5
🔍 Latest deploy log https://app.netlify.com/projects/histoire-site/deploys/69ca1c1402d5e7000803a1bc
😎 Deploy Preview https://deploy-preview-831--histoire-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 30, 2026

Open in StackBlitz

histoire

npm i https://pkg.pr.new/histoire@831

@histoire/app

npm i https://pkg.pr.new/@histoire/app@831

@histoire/controls

npm i https://pkg.pr.new/@histoire/controls@831

@histoire/plugin-nuxt

npm i https://pkg.pr.new/@histoire/plugin-nuxt@831

@histoire/plugin-percy

npm i https://pkg.pr.new/@histoire/plugin-percy@831

@histoire/plugin-screenshot

npm i https://pkg.pr.new/@histoire/plugin-screenshot@831

@histoire/plugin-svelte

npm i https://pkg.pr.new/@histoire/plugin-svelte@831

@histoire/plugin-vue

npm i https://pkg.pr.new/@histoire/plugin-vue@831

@histoire/shared

npm i https://pkg.pr.new/@histoire/shared@831

@histoire/vendors

npm i https://pkg.pr.new/@histoire/vendors@831

commit: 72954c5

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Nuxt 3 example project featuring various components, Histoire stories, and Cypress E2E tests. It also updates the @histoire/plugin-nuxt package to support Nuxt 4 by broadening dependency version ranges. Review feedback identifies missing logic and styles for the 'secondary' variant in BaseButtonLink.vue, recommends removing debug logs in AutoImport.story.vue, and suggests refactoring hardcoded styles in BaseButton.vue. A suggestion was also provided to improve the robustness of Cypress tests by avoiding hardcoded story counts.

Comment on lines +7 to +10
const computedClasses = computed(() => ({
'btn-base': true,
'btn-primary': props.variant === 'primary',
}))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The variant prop accepts 'secondary', but there is no corresponding logic to apply a class for it in computedClasses. This means the secondary variant will not be styled correctly. You should add handling for the secondary variant and define its styles.

Additionally, you'll need to add the corresponding .btn-secondary styles in the <style> block.

const computedClasses = computed(() => ({
  'btn-base': true,
  'btn-primary': props.variant === 'primary',
  'btn-secondary': props.variant === 'secondary',
}))

Comment on lines +2 to +5
console.log('useNuxtApp', useNuxtApp())
console.log('useNuxtApp().$config', useNuxtApp().$config)
const config = useRuntimeConfig()
console.log('useRuntimeConfig', config)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are several console.log statements in the script setup. While they can be useful for debugging during development, they should be removed before merging to avoid polluting the browser console for users of this example. It's a good practice to keep the codebase clean of temporary debugging logs.

const config = useRuntimeConfig()

<template>
<button
:disabled="disabled"
class="btn text-red-500"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The text-red-500 class is hardcoded on the button. This might lead to poor color contrast or unintended styling when different button color props (like 'green') are used. It would be more flexible to either remove this class and rely on the default text color, or to make the text color part of the color variant styles.

    class="btn"

it('should display all stories', () => {
cy.clearLocalStorage()
cy.visit('/')
cy.get('[data-test-id="story-list-item"]').should('have.length', 5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test asserts that there are exactly 5 stories. Using a hardcoded number like this can make the test brittle. If stories are added or removed in this example in the future, this test will fail and will need to be updated. I can see 4 story files being added. If the 5th story is not critical or might be subject to change, consider asserting a minimum number of stories to make the test more robust.

Suggested change
cy.get('[data-test-id="story-list-item"]').should('have.length', 5)
cy.get('[data-test-id="story-list-item"]').should('have.length.gte', 4)

@waldemarennsaed waldemarennsaed mentioned this pull request Mar 30, 2026
4 tasks
@waldemarennsaed
Copy link
Copy Markdown
Contributor Author

@Akryum finally checked out the Nuxt 4 thing and I guess we are good to go. Please have a look. PS: Yes, I was using Claude Code to quickly identify what's wrong and CC suggested to add back Nuxt 3 suite for the tests.

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

Successfully merging this pull request may close these issues.

Add Nuxt4 support

1 participant