feat(nextjs): Allows access to request object to dynamically define clerkMiddleware options - #4160
Conversation
🦋 Changeset detectedLatest commit: 16edd29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
options callback on clerkMiddlewareclerkMiddleware options
b5396ec to
aaf70d7
Compare
aaf70d7 to
8b05418
Compare
8b05418 to
5d2fa46
Compare
5d2fa46 to
525ef29
Compare
|
Hey @LauraBeatris - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@1.3.3-snapshot.v525ef29 --save-exact
npm i @clerk/backend@1.12.0-snapshot.v525ef29 --save-exact
npm i @clerk/chrome-extension@1.3.5-snapshot.v525ef29 --save-exact
npm i @clerk/clerk-js@5.22.0-snapshot.v525ef29 --save-exact
npm i @clerk/elements@0.15.3-snapshot.v525ef29 --save-exact
npm i @clerk/clerk-expo@2.2.11-snapshot.v525ef29 --save-exact
npm i @clerk/express@0.1.0-snapshot.v525ef29 --save-exact
npm i @clerk/fastify@1.0.42-snapshot.v525ef29 --save-exact
npm i @clerk/localizations@3.0.2-snapshot.v525ef29 --save-exact
npm i @clerk/nextjs@5.5.3-snapshot.v525ef29 --save-exact
npm i @clerk/clerk-react@5.9.0-snapshot.v525ef29 --save-exact
npm i @clerk/remix@4.2.26-snapshot.v525ef29 --save-exact
npm i @clerk/clerk-sdk-node@5.0.39-snapshot.v525ef29 --save-exact
npm i @clerk/shared@2.8.0-snapshot.v525ef29 --save-exact
npm i @clerk/tanstack-start@0.4.2-snapshot.v525ef29 --save-exact
npm i @clerk/testing@1.2.22-snapshot.v525ef29 --save-exact
npm i @clerk/themes@2.1.30-snapshot.v525ef29 --save-exact
npm i @clerk/types@4.21.0-snapshot.v525ef29 --save-exact |
clerkMiddleware optionsrequest object when providing clerkMiddleware options
request object when providing clerkMiddleware optionsrequest object to dynamically define clerkMiddleware options
525ef29 to
079b322
Compare
|
Some upcoming docs changes: clerk/clerk-docs#1508 |
LauraBeatris
left a comment
There was a problem hiding this comment.
@royanger mentioned that there was an edge function error when deployment this branch's snapshot to Vercel prod, I'll make another round of tests here
0d0a787 to
7c05c51
Compare
|
!snapshot |
7c05c51 to
cdbc0b0
Compare
|
Hey @LauraBeatris - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@1.3.4-snapshot.v7c05c51 --save-exact
npm i @clerk/backend@1.13.0-snapshot.v7c05c51 --save-exact
npm i @clerk/chrome-extension@1.3.6-snapshot.v7c05c51 --save-exact
npm i @clerk/clerk-js@5.22.1-snapshot.v7c05c51 --save-exact
npm i @clerk/clerk-expo@2.2.12-snapshot.v7c05c51 --save-exact
npm i @clerk/express@0.1.1-snapshot.v7c05c51 --save-exact
npm i @clerk/fastify@1.0.43-snapshot.v7c05c51 --save-exact
npm i @clerk/localizations@3.0.3-snapshot.v7c05c51 --save-exact
npm i @clerk/nextjs@5.6.0-snapshot.v7c05c51 --save-exact
npm i @clerk/remix@4.2.27-snapshot.v7c05c51 --save-exact
npm i @clerk/clerk-sdk-node@5.0.40-snapshot.v7c05c51 --save-exact
npm i @clerk/tanstack-start@0.4.3-snapshot.v7c05c51 --save-exact
npm i @clerk/testing@1.3.1-snapshot.v7c05c51 --save-exact |
|
!snapshot |
|
Hey @LauraBeatris - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@1.3.4-snapshot.v5e85d2f --save-exact
npm i @clerk/backend@1.13.0-snapshot.v5e85d2f --save-exact
npm i @clerk/chrome-extension@1.3.6-snapshot.v5e85d2f --save-exact
npm i @clerk/clerk-js@5.22.1-snapshot.v5e85d2f --save-exact
npm i @clerk/clerk-expo@2.2.12-snapshot.v5e85d2f --save-exact
npm i @clerk/express@0.1.1-snapshot.v5e85d2f --save-exact
npm i @clerk/fastify@1.0.43-snapshot.v5e85d2f --save-exact
npm i @clerk/localizations@3.0.3-snapshot.v5e85d2f --save-exact
npm i @clerk/nextjs@5.6.0-snapshot.v5e85d2f --save-exact
npm i @clerk/remix@4.2.27-snapshot.v5e85d2f --save-exact
npm i @clerk/clerk-sdk-node@5.0.40-snapshot.v5e85d2f --save-exact
npm i @clerk/tanstack-start@0.4.3-snapshot.v5e85d2f --save-exact
npm i @clerk/testing@1.3.1-snapshot.v5e85d2f --save-exact |
5e85d2f to
3a1ab67
Compare
91559f1 to
e940f7f
Compare
|
!snapshot |
|
Hey @LauraBeatris - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@1.3.4-snapshot.ve940f7f --save-exact
npm i @clerk/backend@1.13.0-snapshot.ve940f7f --save-exact
npm i @clerk/chrome-extension@1.3.6-snapshot.ve940f7f --save-exact
npm i @clerk/clerk-js@5.22.1-snapshot.ve940f7f --save-exact
npm i @clerk/dev-cli@0.0.8-snapshot.ve940f7f --save-exact
npm i @clerk/clerk-expo@2.2.12-snapshot.ve940f7f --save-exact
npm i @clerk/express@0.1.1-snapshot.ve940f7f --save-exact
npm i @clerk/fastify@1.0.43-snapshot.ve940f7f --save-exact
npm i @clerk/localizations@3.0.3-snapshot.ve940f7f --save-exact
npm i @clerk/nextjs@5.6.0-snapshot.ve940f7f --save-exact
npm i @clerk/remix@4.2.27-snapshot.ve940f7f --save-exact
npm i @clerk/clerk-sdk-node@5.0.40-snapshot.ve940f7f --save-exact
npm i @clerk/tanstack-start@0.4.3-snapshot.ve940f7f --save-exact
npm i @clerk/testing@1.3.1-snapshot.ve940f7f --save-exact |
|
I've refactored this code since the edge runtime doesn't support We're still using |
70d2b11 to
d1e8331
Compare
tmilewski
left a comment
There was a problem hiding this comment.
👍, pending snapshot testing
e0a67a7 to
139d064
Compare
139d064 to
16edd29
Compare
| "@clerk/nextjs": minor | ||
| --- | ||
|
|
||
| Allows access to request object to dynamically define `clerkMiddleware` options |
There was a problem hiding this comment.
I'll wait on merging this docs PR to reference it in the changeset here
|
@LauraBeatris export default clerkMiddleware((auth, req) => {
return NextResponse.next();
}, {
domain: (req) => req.nextUrl.host,
}) |
@panteliselef I think in that way we'll provide the request specifically to the |
|
Cool, yeah i can see that from the other example u provided. Just wanted to double check. |
… `clerkMiddleware` options (#4160)
Description
Resolves SDK-1932
Allows to dynamically access the Next.js
requestobject when providing options toclerkMiddleware:Another example of a use case where Clerk keys could be fetched based on tenant:
This is another improvement for the "Next.js dynamic keys" feature. So far we propagate
secretKeyandpublishableKeyfrom the middleware to the application server allowing those keys to be provided statically during runtime, but we don't support dynamically resolving per request as in the example above.Checklist
npm testruns as expected.npm run buildruns as expected.Type of change