Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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/ready-cats-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/astro': patch
---

Fixed issue when using ClientRouter where clerk components don't load until navigation is performed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Polish changelog wording/capitalization.

Consider “Clerk” capitalization and a slightly clearer sentence, e.g., “Fixed an issue where Clerk components didn’t load on initial page load when using ClientRouter.”

🤖 Prompt for AI Agents
In @.changeset/ready-cats-tease.md at line 5, Change the changelog line "Fixed
issue when using ClientRouter where clerk components don't load until navigation
is performed" to a polished sentence with proper capitalization and punctuation,
e.g. "Fixed an issue where Clerk components didn’t load on initial page load
when using ClientRouter." Ensure "Clerk" is capitalized and use the improved
wording that mentions "initial page load" instead of "until navigation is
performed."

7 changes: 5 additions & 2 deletions packages/astro/src/integration/create-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ function createIntegration<Params extends HotloadAstroClerkIntegrationParams>()
}

if (transitionEnabledOnThisPage()) {
const { navigate, swapFunctions } = await import('astro:transitions/client');
// We must do the dynamic imports within the event listeners because otherwise we may race and miss initial astro:page-load
document.addEventListener('astro:before-swap', async (e) => {
const { swapFunctions } = await import('astro:transitions/client');

document.addEventListener('astro:before-swap', (e) => {
const clerkComponents = document.querySelector('#clerk-components');
// Keep the div element added by Clerk
if (clerkComponents) {
Expand All @@ -133,6 +134,8 @@ function createIntegration<Params extends HotloadAstroClerkIntegrationParams>()
});

document.addEventListener('astro:page-load', async (e) => {
const { navigate } = await import('astro:transitions/client');

await runInjectionScript({
...${JSON.stringify(internalParams)},
routerPush: navigate,
Expand Down
Loading