Skip to content

feat(astro): Remove createRouteMatcher and support Astro 7#8974

Merged
wobsoriano merged 16 commits into
mainfrom
rob/user-5610-in-astro-7-return-statement-causes-failure
Jul 21, 2026
Merged

feat(astro): Remove createRouteMatcher and support Astro 7#8974
wobsoriano merged 16 commits into
mainfrom
rob/user-5610-in-astro-7-return-statement-causes-failure

Conversation

@wobsoriano

@wobsoriano wobsoriano commented Jun 23, 2026

Copy link
Copy Markdown
Member

Description

This PR does 3 things:

  • Adds Astro 7 support
  • Removes Astro 4 support
  • Removes createRouteMatcher

Docs with migration instructions is ready https://github.com/clerk/clerk/pull/2988

Fixes #9165

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jul 21, 2026 5:51pm
swingset Ready Ready Preview, Comment Jul 21, 2026 5:51pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2cb9fa4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/astro Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: b2fce0f4-5ab6-4fcc-a2a5-7ff5e3b6b179

📥 Commits

Reviewing files that changed from the base of the PR and between 5499148 and 2cb9fa4.

📒 Files selected for processing (2)
  • integration/tests/astro/components.test.ts
  • integration/tests/astro/middleware.test.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual) → reviewed against open PR #2988 rob/astro-crm-removal instead of the default branch
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
🚧 Files skipped from review as they are similar to previous changes (2)
  • integration/tests/astro/components.test.ts
  • integration/tests/astro/middleware.test.ts

📝 Walkthrough

Walkthrough

Updates @clerk/astro to support Astro 5, 6, and 7 while dropping Astro 4. Removes the public createRouteMatcher API and documents moving authentication checks into pages and API routes. The Astro integration template removes Tailwind, updates dependencies, and adds resource-level authentication guards. Integration tests are adjusted for Astro routing behavior, a new Astro v6 compatibility build test is added, and machine authentication requests include an Origin header.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main changes: removing createRouteMatcher and adding Astro 7 support.
Description check ✅ Passed The description matches the changeset and summarizes the Astro 7 support, Astro 4 removal, and createRouteMatcher removal.
Linked Issues check ✅ Passed The PR updates @clerk/astro to allow Astro 7, which directly satisfies issue #9165.
Out of Scope Changes check ✅ Passed The added test and middleware/page refactors are aligned with the stated Astro 7 and createRouteMatcher removal work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jun 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8974

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8974

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8974

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8974

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@8974

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@8974

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@8974

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8974

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@8974

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8974

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8974

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8974

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8974

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8974

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8974

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8974

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8974

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8974

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8974

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8974

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8974

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8974

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8974

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8974

commit: 2cb9fa4

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

dont need tailwind in this...

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-07-21T17:59:25.885Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 1
🔴 Breaking changes 1
🟡 Non-breaking changes 0
🟢 Additions 0

Warning
1 breaking change(s) detected - Major version bump required

🤖 This report was reviewed by claude-sonnet-4-6.

🔴 Breaking changes index (1)

Every breaking change, up front. Full diffs are in the package sections below.

Package Subpath Change
@clerk/astro ./server createRouteMatcher

@clerk/astro

Current version: 3.4.20
Recommended bump: MAJOR → 4.0.0

Subpath ./server

🔴 Breaking Changes (1)

Changed: createRouteMatcher
- createRouteMatcher: (routes: RouteMatcherParam) => (req: Request) => boolean

Static analyzer: Removed function createRouteMatcher

🤖 AI review (confirmed) (97%): The createRouteMatcher function was entirely removed from the public API, so any consumer importing and calling it will fail to compile.

Migration: Import createRouteMatcher from an alternative entry point such as @clerk/astro/server if it was moved, or replace usages with a manual route-matching implementation.


Report generated by Break Check

Last ran on 2cb9fa4.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the change basically just removed the early return; in favor of wrapping the menu-item registration logic in the existing else branch

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Astro v6 compatibility smoke test

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
integration/tests/astro/middleware.test.ts (1)

183-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid a permanent unconditional skip for this regression case.

test.skip(true, ...) disables this check in every run, so routing/auth regressions here can silently reappear. Prefer a tracked test.fixme (with issue ID) or a version-gated skip so coverage returns automatically when the matcher behavior is fixed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@integration/tests/astro/middleware.test.ts` around lines 183 - 186, The
test.skip(true, ...) call unconditionally disables this regression test in every
run, which allows routing and auth regressions to silently reappear. Replace
this with test.fixme(...) that includes a tracked issue ID reference, or
implement version-gated conditional skip logic based on the Astro version so the
test coverage automatically resumes when the routing normalization issue is
resolved. The key is to make the skip temporary and tracked rather than
permanent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@integration/tests/astro/middleware.test.ts`:
- Around line 183-186: The test.skip(true, ...) call unconditionally disables
this regression test in every run, which allows routing and auth regressions to
silently reappear. Replace this with test.fixme(...) that includes a tracked
issue ID reference, or implement version-gated conditional skip logic based on
the Astro version so the test coverage automatically resumes when the routing
normalization issue is resolved. The key is to make the skip temporary and
tracked rather than permanent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b4b2e9c-0535-4606-8b56-033870a8b624

📥 Commits

Reviewing files that changed from the base of the PR and between fecc5e8 and 2db93cb.

📒 Files selected for processing (4)
  • integration/tests/astro/compatibility.test.ts
  • integration/tests/astro/middleware.test.ts
  • packages/astro/package.json
  • packages/astro/src/astro-components/interactive/UserButton/MenuItemRenderer.astro
🚧 Files skipped from review as they are similar to previous changes (3)
  • integration/tests/astro/compatibility.test.ts
  • packages/astro/package.json
  • packages/astro/src/astro-components/interactive/UserButton/MenuItemRenderer.astro

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@integration/testUtils/machineAuthHelpers.ts`:
- Around line 275-281: In the POST request handling blocks, the status assertion
must be moved before the JSON parsing. Currently, the code calls
postWithSessionRes.json() before checking postWithSessionRes.status(), which
means if the response is an error, the json() call may fail before the status
assertion runs, obscuring the actual failure. Reorder the statements so that
expect(postWithSessionRes.status()).toBe(200) is called immediately after the
post request completes, before calling await postWithSessionRes.json(). Apply
this same fix to both the postWithSessionRes block and the similar block
referenced in the "Also applies to" comment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: af4cda56-7137-4065-a8e4-43d80f4d8263

📥 Commits

Reviewing files that changed from the base of the PR and between 2db93cb and a72ad23.

📒 Files selected for processing (1)
  • integration/testUtils/machineAuthHelpers.ts

Comment on lines +275 to 281
const postWithSessionRes = await u.page.request.post(url, {
headers: { Origin: origin },
});
const sessionData = await postWithSessionRes.json();
expect(postWithSessionRes.status()).toBe(200);
expect(sessionData.userId).toBe(fakeBapiUser.id);
expect(sessionData.tokenType).toBe(TokenType.SessionToken);

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Assert response status before parsing JSON bodies in POST branches.

json() can throw on non-JSON error responses before the status assertion runs, which obscures the real failure. Assert status first, then parse.

Suggested patch
       const postWithSessionRes = await u.page.request.post(url, {
         headers: { Origin: origin },
       });
-      const sessionData = await postWithSessionRes.json();
       expect(postWithSessionRes.status()).toBe(200);
+      const sessionData = await postWithSessionRes.json();
       expect(sessionData.userId).toBe(fakeBapiUser.id);
       expect(sessionData.tokenType).toBe(TokenType.SessionToken);

       const postWithApiKeyRes = await u.page.request.post(url, {
         headers: { Authorization: `Bearer ${fakeAPIKey.secret}`, Origin: origin },
       });
-      const apiKeyData = await postWithApiKeyRes.json();
       expect(postWithApiKeyRes.status()).toBe(200);
+      const apiKeyData = await postWithApiKeyRes.json();
       expect(apiKeyData.userId).toBe(fakeBapiUser.id);
       expect(apiKeyData.tokenType).toBe(TokenType.ApiKey);

Also applies to: 283-285

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@integration/testUtils/machineAuthHelpers.ts` around lines 275 - 281, In the
POST request handling blocks, the status assertion must be moved before the JSON
parsing. Currently, the code calls postWithSessionRes.json() before checking
postWithSessionRes.status(), which means if the response is an error, the json()
call may fail before the status assertion runs, obscuring the actual failure.
Reorder the statements so that expect(postWithSessionRes.status()).toBe(200) is
called immediately after the post request completes, before calling await
postWithSessionRes.json(). Apply this same fix to both the postWithSessionRes
block and the similar block referenced in the "Also applies to" comment.

@wobsoriano

Copy link
Copy Markdown
Member Author

!allow-major

@wobsoriano wobsoriano changed the title feat(astro): Support Astro v7 feat(astro): Remove createRouteMatcher and support Astro 7 Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@integration/templates/astro-node/src/pages/discover.astro`:
- Around line 5-9: Add an end-to-end signed-out navigation test in the existing
Astro component test suite for `/discover`, asserting it redirects to the
sign-in route. Reuse the test’s established navigation and redirect assertion
patterns, and ensure the test covers the guard introduced in the `/discover`
page.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 99030421-dd59-4675-b8fc-a285043b53d5

📥 Commits

Reviewing files that changed from the base of the PR and between a72ad23 and 5499148.

📒 Files selected for processing (12)
  • .changeset/floppy-buckets-help.md
  • .changeset/major-astro-remove-route-matcher.md
  • integration/templates/astro-node/src/middleware.ts
  • integration/templates/astro-node/src/pages/api/protected/current-org.ts
  • integration/templates/astro-node/src/pages/api/protected/only-admin.ts
  • integration/templates/astro-node/src/pages/discover.astro
  • integration/templates/astro-node/src/pages/user.astro
  • integration/tests/astro/components.test.ts
  • integration/tests/astro/middleware.test.ts
  • packages/astro/package.json
  • packages/astro/src/server/index.ts
  • packages/astro/src/server/route-matcher.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
💤 Files with no reviewable changes (2)
  • packages/astro/src/server/route-matcher.ts
  • packages/astro/src/server/index.ts

Comment thread integration/templates/astro-node/src/pages/discover.astro
@wobsoriano
wobsoriano merged commit 237748d into main Jul 21, 2026
51 checks passed
@wobsoriano
wobsoriano deleted the rob/user-5610-in-astro-7-return-statement-causes-failure branch July 21, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@clerk/astro should allow new Astro major version as a dependency

4 participants