Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "WIP: Update react-sdk.mdx" #352

Merged
merged 1 commit into from
Mar 3, 2025
Merged

Conversation

clairekinde11
Copy link
Collaborator

@clairekinde11 clairekinde11 commented Mar 3, 2025

Waiting on package

Summary by CodeRabbit

  • Documentation

    • Updated the React SDK documentation with clear, refined code examples optimized for React 18.2.0.
    • Revised guidance for authentication flows, emphasizing hook-based login and registration with improved parameter conventions.
  • New Features

    • Streamlined the authentication process with a unified callback.
    • Added enhanced methods for organization management, token retrieval, permission checks, and feature flag handling.

Copy link
Contributor

coderabbitai bot commented Mar 3, 2025

Walkthrough

The changes update the Kinde React SDK documentation to reflect specific improvements: the SDK is now optimized for React 18.2.0, and sign in/sign up flows have been rephrased to use a dedicated React hook rather than separate link components. The callback mechanism has been consolidated into a single onRedirectCallback, and method signatures have been modified—parameters for login and registration now use an authUrlParams object with snake_case naming. Additionally, the SDK now introduces new methods for organization creation and flag retrieval while updating existing permission and claim retrieval functionalities.

Changes

File(s) Change Summary
src/content/docs/developer-tools/sdks/.../react-sdk.mdx Updated documentation for the Kinde React SDK: clarifications on sign in/sign up flows, React 18.2.0 optimization, and revised code examples.
API Changes (useKindeAuth) Updated method signatures: getToken() replaces getAccessToken(), token parameter in getClaim changed from idToken to id_token, and permissions/flags return structures refined. Added new methods: createOrg, getBooleanFlag, getStringFlag, and getIntegerFlag.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant SDK as useKindeAuth Hook
    participant Auth as Authentication Service

    U->>SDK: Initiate login(authUrlParams)
    SDK->>Auth: Redirect with authUrlParams
    Auth-->>SDK: Return user and app state via redirection
    SDK->>SDK: Invoke onRedirectCallback with state
Loading

Suggested reviewers

  • marcosmartini

Poem

I hopped through lines of code with glee,
Updating methods and flags so free.
New hooks and flows under React’s light,
Guiding developers day and night.
With each tweak, my heart feels bright—
A rabbit’s cheer for changes done just right!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the sdk label Mar 3, 2025
Copy link

Deploying kinde-docs-previews with  Cloudflare Pages  Cloudflare Pages

Latest commit: 96d0c74
Status: ✅  Deploy successful!
Preview URL: https://5beb3f00.kinde-docs-previews.pages.dev
Branch Preview URL: https://revert-335-feat-react-v5.kinde-docs-previews.pages.dev

View logs

@clairekinde11 clairekinde11 requested a review from viv-kinde March 3, 2025 01:42
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/content/docs/developer-tools/sdks/frontend/react-sdk.mdx (5)

82-89: Refine the redirect callback section wording.
The description—“…any application state you set prior to the redirect”—could be simplified to “before the redirect” for improved clarity. The onRedirectCallback code snippet is clear and concise.

🧰 Tools
🪛 LanguageTool

[style] ~84-~84: ‘prior to’ might be wordy. Consider a shorter alternative.
Context: ...bject and any application state you set prior to the redirect. ```jsx onRedirectCallbac...

(EN_WORDINESS_PREMIUM_PRIOR_TO)


98-99: Improve punctuation and possessive forms in parameter descriptions.
Consider revising the bullet points to:
• “login_hint – this allows you to ask Kinde to prepopulate a user's email address…”
• “lang – if you offer multi-language support, Kinde will automatically figure out the best language for your user; however, if you want to force a language and override the user's preference, you can do so by passing this attribute.”
This will enhance readability.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~98-~98: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...llows you to ask Kinde to prepopulate a users email address on the sign-up and sign-i...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


[uncategorized] ~99-~99: Possible missing comma found.
Context: ...s. - lang if you offer multi-language support Kinde will automatically figure out the...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~99-~99: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...nt to force a language and override the users preference, you can do so by passing th...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


146-165: Examine the UserProfile component’s JSX structure.
While the component correctly handles the loading state and displays the user’s first name and preferred email, the return statement wraps the conditional rendering within an extra set of curly braces. This pattern can lead to unexpected results in JSX. Consider using a fragment or returning the conditional expression directly.


375-375: Review the explanatory text for feature flag wrappers.
The line “We also require wrapper functions by type which should leverage getFlag above.” may benefit from a slight punctuation improvement (e.g., inserting a comma after “flag”).

🧰 Tools
🪛 LanguageTool

[uncategorized] ~375-~375: Possible missing comma found.
Context: ... We also require wrapper functions by type which should leverage getFlag` above. ...

(AI_HYDRA_LEO_MISSING_COMMA)


339-347: Examine the JSDoc for the getFlag helper function.
The documentation is informative; however, consider updating the parameter type for defaultValue from “obj” to “object” for clarity and consistency with typical JSDoc conventions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 865fabb and 96d0c74.

📒 Files selected for processing (1)
  • src/content/docs/developer-tools/sdks/frontend/react-sdk.mdx (11 hunks)
🧰 Additional context used
🪛 LanguageTool
src/content/docs/developer-tools/sdks/frontend/react-sdk.mdx

[style] ~84-~84: ‘prior to’ might be wordy. Consider a shorter alternative.
Context: ...bject and any application state you set prior to the redirect. ```jsx onRedirectCallbac...

(EN_WORDINESS_PREMIUM_PRIOR_TO)


[uncategorized] ~98-~98: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...llows you to ask Kinde to prepopulate a users email address on the sign-up and sign-i...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


[uncategorized] ~99-~99: Possible missing comma found.
Context: ...s. - lang if you offer multi-language support Kinde will automatically figure out the...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~99-~99: It seems likely that a singular genitive (’s) apostrophe is missing.
Context: ...nt to force a language and override the users preference, you can do so by passing th...

(AI_HYDRA_LEO_APOSTROPHE_S_XS)


[uncategorized] ~143-~143: Possible missing comma found.
Context: ...t_name}!

; }; ``` To be on the safe side we have also provided isAuthenticated...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~193-~193: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ... working on more. You can also use any open source JWT verification library for your langu...

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[uncategorized] ~197-~197: Possible missing comma found.
Context: ...nded recipient of an access token - for example the API for your application. The `audi...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~375-~375: Possible missing comma found.
Context: ... We also require wrapper functions by type which should leverage getFlag` above. ...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (23)
src/content/docs/developer-tools/sdks/frontend/react-sdk.mdx (23)

17-17: Review the React version optimization note.
The updated line “This SDK is optimized for React version 18.2.0.” changes the React version detail. Given that this PR is a reversion of a WIP update, please verify that this change is either intentional or should be reverted to the previous text.


66-68: Examine the sign in & sign up section header and description.
The revised header (“## Sign in and sign up”) and accompanying text now emphasize the use of the React hook for login/register flows. Confirm that this change aligns with the intended documentation state post-reversion.


73-79: Review the login/register hook usage code snippet.
The snippet properly imports useKindeAuth and destructures the login and register methods for use in button handlers. Ensure that any references to previous components (such as separate link components) have been fully removed as per the latest documentation guidance.


101-115: Validate the login example with additional auth URL parameters.
The code clearly demonstrates how to pass an authUrlParams object with snake_case keys (login_hint and lang). Please ensure that this example remains consistent with the expected API behavior.


117-125: Confirm the sign-out example correctness.
The snippet for logging out via useKindeAuth is straightforward. Verify that the updated documentation still intends to use this approach for signing out after the reversion.


136-141: Review the simple user greeting example.
The SayHello component correctly demonstrates importing useKindeAuth and using the user object to display a greeting. Ensure consistency with the rest of the documentation examples.


173-189: Assess the API call example using getToken.
The provided asynchronous example demonstrates token retrieval and an API call via fetch effectively. Please confirm that the placeholder <your-api> will be replaced appropriately in production documentation.


219-223: Verify the organization creation section heading and introduction.
The headers “## Organizations” and “### Create an organization” along with the introductory text are clear. Double-check that these descriptions align with the reverted documentation’s intent regarding organization management.


226-231: Review the createOrg usage example.
The code snippet effectively illustrates how to import and invoke createOrg from useKindeAuth. Ensure that any accompanying text also reflects the reverted functionality if applicable.


233-238: Examine the instructions for signing users into organizations.
The section now clearly instructs the user to pass an org_code during registration or login. Verify that this updated guidance matches the currently supported API and that it aligns with the overall documentation style after reversion.


286-289: Review the permission helper functions usage examples.
The snippet demonstrating getPermission("create:todos") and getPermissions() is concise and effective. Confirm that the documented return structures match the latest API specifications.


295-298: Verify the conditional rendering for permissions.
The example showing how to conditionally render a button based on the permission's isGranted flag is clear. Ensure that the JSX syntax is correct within the broader context of the documentation.


349-356: Validate the getFlag example usage.
The code snippet that calls getFlag('theme') and includes a commented expected output is clear. Ensure that the formatting and inline comments match the documentation style used throughout the file.


368-372: Review the conditional rendering example for feature flags.
The snippet that conditionally renders a button based on getFlag("create_competition").value is concise and clear. Verify that it accurately reflects how feature flags are intended to be used.


379-387: Evaluate the JSDoc for the getBooleanFlag helper.
The commentary and function signature explanation are clear. Confirm that the type annotations and descriptions align with the overall documentation standards.


388-391: Confirm the example usage for getBooleanFlag.
The usage example properly demonstrates calling getBooleanFlag("is_dark_mode") and expectations for its output.


392-397: Verify the default value behavior in the getBooleanFlag example.
The demonstration using a default fallback value is clear and correctly documents the behavior when a flag does not exist.


401-409: Review the JSDoc for the getStringFlag helper.
The documentation is clear and informative. If needed, consider explicitly stating that an empty string (or another falsy value) may be used as a default.


410-417: Review the JSDoc for the getIntegerFlag helper.
The explanation and type annotations are appropriate. Verify that the documentation meets the overall formatting and detail standards.


421-427: Assess the combined feature flag usage example.
The snippet effectively shows how to combine getBooleanFlag and getStringFlag to conditionally render a button with a dynamic class name. Ensure that the JSX syntax and use of template literals are correct.


443-447: Review the KindeProvider scope override example.
The example correctly demonstrates overriding the default scope by explicitly specifying scope="openid". Confirm that the ellipsis (...) are intended placeholders for additional properties.


455-462: Evaluate the getClaim helper usage example.
The snippet shows both a basic claim retrieval and one that specifies "id_token", which is clear and accurate.


498-504: Review the redirect handler code snippet.
The example for handling redirection post-authentication is clear. Consider whether using window.location without a property (e.g., window.location.href) is preferable for clarity, though the current implementation is acceptable if it meets project conventions.

Comment on lines +240 to 242
<button onClick={() => register({org_code: ‘org_1234’})} type="button">Register</button>
<button onClick={() => login({org_code: ‘org_1234})} type="button">Sign in</button>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typographic quotes in organization sign up/sign in examples.
The code examples use curly quotes (‘org_1234’) which can lead to syntax errors. Replace these with standard single quotes ('org_1234').

@clairekinde11 clairekinde11 merged commit 488a70b into main Mar 3, 2025
5 checks passed
@clairekinde11 clairekinde11 deleted the revert-335-feat/react-v5 branch March 3, 2025 01:58
@coderabbitai coderabbitai bot mentioned this pull request Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants