Skip to content

Conversation

@Kyleasmth
Copy link
Collaborator

useYVAuth falls back to authRedirectUrl configured in YouVersionProvider so the prop isn't needed.

… useYVAuth falls back to authRedirectUrl configured in YouVersionProvider.
@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2026

⚠️ No Changeset found

Latest commit: 3992c07

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@Kyleasmth Kyleasmth requested a review from bmanquen January 26, 2026 15:14
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

Made the redirectUrl prop optional on YouVersionAuthButton component by changing the interface definition from redirectUrl: string to redirectUrl?: string.

  • The useYVAuth hook already supports fallback behavior - when redirectUrl is not provided in the signIn params, it falls back to the authRedirectUrl configured in YouVersionProvider
  • This simplifies the component API by allowing consumers to omit redirectUrl when they've already configured it globally in the provider
  • Existing usages passing redirectUrl explicitly will continue to work unchanged
  • The component correctly passes the optional redirectUrl to signIn() at line 138, which handles the fallback logic

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is minimal and well-aligned with existing behavior - useYVAuth already handles optional redirectUrl with fallback to provider config, this just exposes that capability at the component level
  • No files require special attention

Important Files Changed

Filename Overview
packages/ui/src/components/YouVersionAuthButton.tsx Made redirectUrl prop optional on SignInAuthProps interface - falls back to provider config

Sequence Diagram

sequenceDiagram
    participant User
    participant Button as YouVersionAuthButton
    participant Hook as useYVAuth
    participant Provider as YouVersionProvider
    participant API as YouVersionAPIUsers

    User->>Button: Click
    Button->>Hook: signIn(options)
    
    alt URL in options
        Hook->>API: Use options.redirectUrl
    else No URL in options
        Hook->>Provider: Fallback to config
        Provider-->>Hook: authRedirectUrl
        Hook->>API: Use authRedirectUrl
    end
    
    API-->>User: Redirect to OAuth
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@cameronapak
Copy link
Collaborator

@greptileai, what would it take to mark redirectUrl prop in the YouVersionAuthButton as deprecated, so that we can encourage the user to use the YouVersionProvider prop instead?

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 26, 2026

To mark the redirectUrl prop as deprecated in YouVersionAuthButton, you'll need to make these changes:

1. Make the prop optional and add deprecation JSDoc

Update the SignInAuthProps interface in packages/ui/src/components/YouVersionAuthButton.tsx:13:

interface SignInAuthProps {
  /**
   * Called when the sign-in flow fails.
   * @param error - The error thrown by the sign-in flow.
   */
  onAuthError?: (error: Error) => void;
  scopes?: AuthenticationScopes[];
  /**
   * @deprecated Use the `authRedirectUrl` prop on YouVersionProvider instead. 
   * This prop will be removed in a future version.
   * 
   * The redirect URL for the authentication flow.
   */
  redirectUrl?: string;
}

2. Add console warning for deprecated usage

Update the handleClick function in the component to warn when the deprecated prop is used:

const handleClick = async (e: React.MouseEvent<HTMLButtonElement>): Promise<void> => {
  e.preventDefault();

  if (onClick) {
    onClick(e);
  }

  // Warn about deprecated prop usage
  if (redirectUrl && process.env.NODE_ENV !== 'production') {
    console.warn(
      'YouVersionAuthButton: The `redirectUrl` prop is deprecated. ' +
      'Use the `authRedirectUrl` prop on YouVersionProvider instead. ' +
      'This prop will be removed in a future version.'
    );
  }

  try {
    if (mode === 'signOut' || auth.isAuthenticated) {
      signOut();
    } else {
      await signIn({
        redirectUrl,
        scopes,
      });
    }
  } catch (error) {
    if (onAuthError) {
      onAuthError(error as Error);
    }
  }
};

3. Update the JSDoc example

Update the main component JSDoc to show the new recommended pattern:

/**
 * @example
 * // Recommended: Configure redirect URL in provider
 * <YouVersionProvider authRedirectUrl="https://myapp.com/callback">
 *   <YouVersionAuthButton onAuthError={(err) => console.error(err)} />
 * </YouVersionProvider>
 * 
 * @example
 * // Deprecated: Direct redirectUrl prop (still works but will be removed)
 * <YouVersionAuthButton
 *   redirectUrl="https://myapp.com/callback" // deprecated
 *   onAuthError={(err) => console.error(err)}
 * />
 */

These changes will:

  • ✅ Make the prop optional (non-breaking)
  • ✅ Clearly mark it as deprecated in TypeScript/IDE tooltips
  • ✅ Warn developers in development builds
  • ✅ Provide clear migration guidance
  • ✅ Maintain backward compatibility

The fallback behavior in useYVAuth already handles the case where no redirectUrl is passed, so existing functionality will continue to work seamlessly.

…ecate its usage in favor of authRedirectUrl in YouVersionProvider.
@Kyleasmth Kyleasmth requested a review from cameronapak January 26, 2026 19:09
Copy link
Collaborator

@bmanquen bmanquen left a comment

Choose a reason for hiding this comment

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

Add changeset

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.

4 participants