Skip to content

Update hank-elements to v3 - #355

Open
Harm-Nullix wants to merge 38 commits into
nuxt-modules:mainfrom
Harm-Nullix:merge-to-hanko
Open

Update hank-elements to v3#355
Harm-Nullix wants to merge 38 commits into
nuxt-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
Comment thread src/runtime/composables/index.ts Outdated
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

codecov Bot commented Jan 5, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #355       +/-   ##
===========================================
+ Coverage   36.82%   84.37%   +47.54%     
===========================================
  Files          16        1       -15     
  Lines         410       32      -378     
  Branches       25        9       -16     
===========================================
- Hits          151       27      -124     
+ Misses        245        3      -242     
+ Partials       14        2       -12     

☔ View full report in Codecov by Harness.
📢 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!

# Conflicts:
#	README.md
#	playground/package.json
#	pnpm-lock.yaml
# Conflicts:
#	README.md
#	package.json
#	playground/package.json
#	pnpm-lock.yaml
#	pnpm-workspace.yaml
@Harm-Nullix Harm-Nullix changed the title Update hank-elements to v2 Update hank-elements to v3 Jul 1, 2026
@Harm-Nullix

Copy link
Copy Markdown
Author

@danielroe , I know you are a busy guy and I hate to bother but..
Can you please take a look at this?

Hank released to v3 last month, and this package still is on V1.
I've been running my own branch for half a year now on production without any bugs or problems.
Now I've bumped to V3 where there are little changes but still one important API change.
No issues found.

I've bumped this PR branch to V3 and merged all commits from main into it.
Some checks fail, but that is because of the merged linting, not of the changes I've made.

Or so help me, make me a maintainer..

With love from the Netherlands

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