Skip to content

Update hank-elements to v2#355

Open
Harm-Nullix wants to merge 6 commits intonuxt-modules:mainfrom
Harm-Nullix:merge-to-hanko
Open

Update hank-elements to v2#355
Harm-Nullix wants to merge 6 commits intonuxt-modules:mainfrom
Harm-Nullix:merge-to-hanko

Conversation

@Harm-Nullix
Copy link
Copy Markdown

🔗 Linked issue

#3
This change does require a new major version!
❓ Type of change

📖 Documentation (updates to the documentation or readme)
🐞 Bug fix (a non-breaking change that fixes an issue)
[x ] 👌 Enhancement (improving an existing functionality)

✨ New feature (a non-breaking change that adds functionality)
[x ] 🧹 Chore (updates to the build process or auxiliary tools and libraries)
[x ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Every running instance of Hanko does a session/validate ever so often.
When using useHanko on multiple plugins / middleware / pages, a lot of instances are polling.
We can prevent that by using useState

Hank elements are currenlty on v 2.3.
I've updated the package and places that have changed so the middleware works again

@Harm-Nullix Harm-Nullix requested a review from danielroe as a code owner January 3, 2026 10:45
@Harm-Nullix Harm-Nullix mentioned this pull request Jan 3, 2026
3 tasks
cookieDomain: hankoConfig.cookieDomain,
})

const hanko = useState(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we should probably use nuxtApp.provide('hanko', hankoInstance) (and then nuxtApp.$hanko) rather than useState as state is really meant to be for data that could be passed from server -> client.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I agree.
I've changed it to a provide from within the client plugin and added the types there as well.
My second commit is updating the documentation and inner usage of the provided $hanko instead of useHanko()
I kept useHanko alive because of compatibility.
I hope you agree on this.
Thanks for the catch.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would rather keep useHanko (and use everywhere instead of nuxtApp.$hanko) but we can return nuxtApp.$hanko inside it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fair enough, I reverted it within the src folder

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.87%. Comparing base (c8d99bf) to head (6ae13dd).
⚠️ Report is 300 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #355       +/-   ##
===========================================
+ Coverage   36.82%   83.87%   +47.04%     
===========================================
  Files          16        1       -15     
  Lines         410       31      -379     
  Branches       25        8       -17     
===========================================
- Hits          151       26      -125     
+ Misses        245        3      -242     
+ Partials       14        2       -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Harm-Nullix
Copy link
Copy Markdown
Author

Resolved merge conflict, cheers!

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.

2 participants