Conversation
…ent multiple instances that poll /session/validation
src/runtime/composables/index.ts
Outdated
| cookieDomain: hankoConfig.cookieDomain, | ||
| }) | ||
|
|
||
| const hanko = useState( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I would rather keep useHanko (and use everywhere instead of nuxtApp.$hanko) but we can return nuxtApp.$hanko inside it.
There was a problem hiding this comment.
Fair enough, I reverted it within the src folder
…or Hanko instance
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
Resolved merge conflict, cheers! |
🔗 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)
📚 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