Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pretty-peas-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/astro": patch
---

Fix incorrect authentication state when subscribing to client stores.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@clerk/shared": "2.5.2",
"@clerk/types": "4.14.0",
"nanoid": "5.0.7",
"nanostores": "0.10.3",
"nanostores": "0.11.2",
Copy link
Member Author

Choose a reason for hiding this comment

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

Version bump with bug fixes and perf improvements. No breaking change. See changelog

"path-to-regexp": "6.2.2"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/stores/external.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deriveState } from '@clerk/shared/deriveState';
import { eventMethodCalled } from '@clerk/shared/telemetry';
import { computed, onMount, type Store } from 'nanostores';
import { batched, computed, onMount, type Store } from 'nanostores';

import { $clerk, $csrState, $initialState } from './internal';

Expand All @@ -13,7 +13,7 @@ import { $clerk, $csrState, $initialState } from './internal';
*
* $authStore.subscribe((auth) => console.log(auth.userId))
*/
export const $authStore = computed([$csrState, $initialState], (state, initialState) => {
export const $authStore = batched([$csrState, $initialState], (state, initialState) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this return a read only store similar to computed ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes readonly too

return deriveState(
state.isLoaded,
{
Expand Down
8 changes: 4 additions & 4 deletions packages/astro/src/stores/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export const $csrState = map<{
organization: OrganizationResource | undefined | null;
}>({
isLoaded: false,
client: null,
user: null,
session: null,
organization: null,
client: undefined,
user: undefined,
session: undefined,
organization: undefined,
Comment on lines +19 to +22
Copy link
Member Author

Choose a reason for hiding this comment

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

See my comment here. Putting the update here as they're related

});

export const $initialState = map<InitialState>();
Expand Down