Skip to content

docs(nextjs): point the sample, JSDoc and quick start at the middleware entry point - #552

Open
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-middleware-import-path
Open

docs(nextjs): point the sample, JSDoc and quick start at the middleware entry point#552
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-middleware-import-path

Conversation

@DonOmalVindula

Copy link
Copy Markdown
Contributor

Problem

asgardeoMiddleware and createRouteMatcher moved to the Edge-safe @asgardeo/nextjs/middleware entry point in d6b5cba (token refresh in the middleware), but nothing that points users at the middleware followed:

  • samples/teamspace-nextjs/middleware.ts still imports them from @asgardeo/nextjs/server, which no longer exports them, so the sample does not build. CI's E2E suite only runs the React sample, so this went unnoticed.
  • The JSDoc examples on asgardeoMiddleware import from the package root, which never exported it.
  • QUICKSTART.md describes a new AsgardeoNext() / asgardeo.middleware(request) setup that does not exist (the constructor is private and there is no middleware() method), and configures the embedded sign-in page path through that non-existent API.

Fix

  • Sample and JSDoc examples import from @asgardeo/nextjs/middleware.
  • Quick start: the middleware step uses asgardeoMiddleware() from the middleware entry point; the embedded login step configures the sign-in page through NEXT_PUBLIC_ASGARDEO_SIGN_IN_URL, which both the provider and the middleware read (SignInButton navigates there, protectRoute() redirects there). The stray "Auth.js" references in the intro and resources are dropped.
  • README gains a short "Middleware" section explaining the entry point and why the root/server entries cannot be used from middleware.ts.

Re-exporting the middleware from /server for backward compatibility was deliberately not done: that entry pulls @asgardeo/node (and its Node-only dependencies) into the Edge bundle, which is what the separate entry point avoids.

Testing

  • pnpm lint for @asgardeo/nextjs; the ./middleware export condition and dist/types/middleware.d.ts are present in the build.
  • The sample is excluded from the pnpm workspace, so it was not built here.

Changeset included (@asgardeo/nextjs patch).

🤖 Generated with Claude Code

…re entry point

asgardeoMiddleware and createRouteMatcher moved to the Edge-safe
`@asgardeo/nextjs/middleware` entry point when the token refresh was added to
the middleware, but the bundled sample still imported them from
`@asgardeo/nextjs/server` (which no longer exports them), the JSDoc examples
imported them from the package root, and the quick start described a
`new AsgardeoNext()` / `asgardeo.middleware()` setup that never existed.

- Fix the imports in samples/teamspace-nextjs and the JSDoc examples.
- Rewrite the quick start's middleware step and the embedded login step
  (the sign-in page path is configured through NEXT_PUBLIC_ASGARDEO_SIGN_IN_URL,
  which both the provider and the middleware read); drop the stray Auth.js
  references.
- Document the middleware entry point in the README.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 8baed1d6-065b-4217-85cb-4138c1540cde

📥 Commits

Reviewing files that changed from the base of the PR and between 409ebae and ea4a282.

📒 Files selected for processing (5)
  • .changeset/nextjs-middleware-import-path.md
  • packages/nextjs/QUICKSTART.md
  • packages/nextjs/README.md
  • packages/nextjs/src/server/middleware/asgardeoMiddleware.ts
  • samples/teamspace-nextjs/middleware.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@asgardeo-github-bot

Copy link
Copy Markdown

🦋 Changeset detected

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants