Skip to content

Comments

Add use-client directive#530

Merged
marcospassos merged 1 commit intomasterfrom
use-client-directive
Mar 19, 2025
Merged

Add use-client directive#530
marcospassos merged 1 commit intomasterfrom
use-client-directive

Conversation

@marcospassos
Copy link
Member

Summary

Add the "use client" directive to all hooks to ensure SSR frameworks don't strip the hook logic from the client side.

In the Next.js SDK, the hook initially returns default content on the server and then requests personalized content on the client. However, if the component using the hook doesn't contain client-only code, Next.js assumes there's no dynamic logic, stripping out the SDK’s functionality from the client-side bundle. This PR explicitly marks the hooks as client code to prevent that behavior.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@marcospassos marcospassos added the enhancement New feature or request label Mar 19, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 19, 2025

Open in Stackblitz

npm i https://pkg.pr.new/@croct/plug-react@530

commit: cfa8940

@marcospassos marcospassos merged commit 79977f2 into master Mar 19, 2025
20 checks passed
@marcospassos marcospassos deleted the use-client-directive branch March 19, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant