Skip to content

Conversation

@Harm-Nullix
Copy link

πŸ”— 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
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
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
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
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

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 (df09451).
⚠️ Report is 274 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.

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