feat: add 'use client' directive to bundles for RSC support - #1179
feat: add 'use client' directive to bundles for RSC support#1179gyaneshgouraw-okta wants to merge 6 commits into
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRollup adds ChangesClient Directive Support
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@__tests__/use-client-directive.test.tsx`:
- Around line 54-60: Replace the generic process.env.CI guard in the
missing-bundle check of use-client-directive.test.tsx with an explicit
directive-verification environment flag. In .github/workflows/test.yml lines
86-87, set that flag only on the rsc-directive npm run test:dist step; leave the
unit job unchanged.
In @.github/workflows/test.yml:
- Around line 74-75: Update the actions/checkout step in the workflow to disable
persisted credentials by setting persist-credentials to false, ensuring the
checkout token is not retained for later project-controlled steps.
In `@EXAMPLES.md`:
- Line 497: Update the Server Components guidance in EXAMPLES.md to specifically
state that useAuth0() must be called from a Client Component because it depends
on Auth0 context and browser APIs. Remove the broad claim that any hook call
requires a Client Component, while preserving the instruction to use 'use
client' for components invoking useAuth0().
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f68b6605-f252-475a-9691-994e43e04f29
📒 Files selected for processing (6)
.github/workflows/test.ymlEXAMPLES.md__tests__/use-client-directive.test.tsxpackage.jsonrollup.config.mjssrc/auth0-provider.tsx
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Gyanesh Gouraw <160731216+gyaneshgouraw-okta@users.noreply.github.com>
Summary
Adds React Server Components support so
@auth0/auth0-reactworks with the Next.js App Router. The published ESM and CommonJS bundles now ship a top-level'use client'directive, letting you importAuth0Providerdirectly into a Server Component (e.g.app/layout.tsx) without writing a custom'use client'wrapper. Components that call hooks likeuseAuth0()are still Client Components, per standard RSC rules.Changes
'use client'directive at the top of the built ESM and CommonJS bundles via Rollup'soutput.banner(the UMD<script>builds intentionally omit it).dist/is not built, so the guarantee can never silently pass.test:distscript that builds then runs the directive test.redirect_urifrom the Server Component instead ofwindow.location.origin.Example
Testing
npm run test:dist— builds the bundles and runs the directive suite (4 passing: 2 RSC bundles carry the directive, 2 UMD bundles don't).bannerfrom the Rollup config and rebuilding makes the corresponding RSC assertion fail.CI=truewith nodist/throws instead of skipping; withoutCIit skips with a warning.npm testfull unit suite passes (147 tests);npm run lintclean.Summary by CodeRabbit
'use client'directive in distribution bundles used with React Server Components (CJS/ESM).Auth0Providerwith the Next.js App Router, including example placement and client-only hook constraints.'use client'placement in built artifacts.test:dist) to run the directive verification during build validation.