Skip to content

Conversation

guilherme6191
Copy link
Member

@guilherme6191 guilherme6191 commented Oct 3, 2025

Description

This PR adds locale to signup flow. If it's not passed by users, we retrieve it from the browser. If the value we get from the browser can be determined (trying to narrow it down to BPC 147 spec), we don't infer and set the default to null.

Related PRs for extra context, if needed:

Note: this shouldn't have issues in Expo (the inferring) , but we might want to explore expo-localization in the future or as a follow-up for a expo specific solution.

https://linear.app/clerk/issue/USER-3606/retrieve-and-send-locale-information-with-sign-ups

Checklist

  • generate changeset

  • pnpm test runs as expected.

  • pnpm build runs as expected.

  • (If applicable) JSDoc comments have been added or updated for any package exports

  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Sign-up now accepts, persists and exposes a locale value; browser locale is used when not provided.
  • Tests

    • Added unit tests for browser-locale detection across multiple scenarios.
  • Documentation

    • Playground README updated to use localhost:4011.
  • Chores

    • Added browser-locale utility and re-export; updated fixtures, proxies and public types to include locale; broadened .env ignore rules; release metadata updated.

Copy link

changeset-bot bot commented Oct 3, 2025

🦋 Changeset detected

Latest commit: e07029d

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

This PR includes changesets to release 22 packages
Name Type
@clerk/clerk-js Minor
@clerk/clerk-react Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/elements Patch
@clerk/nextjs Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nuxt Patch
@clerk/shared Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/vue Patch

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

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

Copy link

vercel bot commented Oct 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Oct 9, 2025 4:55pm

Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Adds browser-derived locale support for sign-ups: new getBrowserLocale utility and tests; locale field added to SignUp/SignUpFuture, types, JSON and fixtures; SignUp.create/SignUpFuture.create inject locale when missing; SignUp serialization/deserialization and React state proxy expose locale; minor playground updates.

Changes

Cohort / File(s) Summary
SignUp locale integration
packages/clerk-js/src/core/resources/SignUp.ts
Adds public locale: string | null; fromJSON/__internal_toSnapshot read/serialize locale; SignUp.create and SignUpFuture.create inject getBrowserLocale() when locale is missing and include it in request payloads; SignUpFuture proxies locale.
Locale utility + tests + re-export
packages/clerk-js/src/utils/locale.ts, packages/clerk-js/src/utils/index.ts, packages/clerk-js/src/utils/__tests__/locale.test.ts
New getBrowserLocale(): string | null with in-browser guard, validation and safe error handling; re-exported from utils index; unit tests for present/undefined/empty/missing navigator using vi.stubGlobal.
Types: SignUp resource and params
packages/types/src/signUp.ts, packages/types/src/signUpCommon.ts, packages/types/src/signUpFuture.ts, packages/types/src/json.ts
Adds locale: string | null to SignUpResource/SignUpJSON; optional locale?: string to SignUpCreateParams and SignUpFutureAdditionalParams; adds locale to future resource types.
Test fixtures
packages/clerk-js/src/test/core-fixtures.ts
createSignUp fixture now includes legal_accepted_at and locale from params in produced SignUpJSON.
React state proxy
packages/react/src/stateProxy.ts
Added locale getter on signUp proxy exposing locale via gateProperty(target, 'locale', null).
Playground housekeeping
playground/app-router/.gitignore, playground/app-router/README.md
.gitignore updated to ignore .env* and /.clerk/; README example URLs updated from localhost:3000 to localhost:4011.
Changeset
.changeset/funny-memes-crash.md
Adds a changeset noting "Add support for sign up locale" and bumps relevant packages.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as App UI
  participant Client as SignUp client
  participant Util as getBrowserLocale()
  participant API as Backend API

  User->>UI: Submit sign-up (params may omit locale)
  UI->>Client: SignUp.create(params)
  alt params.locale provided
    Client->>API: POST /sign-ups { ..., locale }
  else params.locale missing
    Client->>Util: getBrowserLocale()
    Util-->>Client: locale or null
    Client->>API: POST /sign-ups { ..., locale? }
  end
  API-->>Client: 201 Created { locale }
  Client-->>UI: SignUpResource { locale }
Loading
sequenceDiagram
  autonumber
  actor User
  participant UI as App UI
  participant Future as SignUpFuture
  participant Util as getBrowserLocale()
  participant API as Backend API

  User->>UI: Start future sign-up
  UI->>Future: SignUpFuture.create(params?)
  alt params.locale missing
    Future->>Util: getBrowserLocale()
    Util-->>Future: locale or null
  end
  Future->>API: POST /sign-ups { ..., locale? }
  API-->>Future: 201 Created { locale }
  Future-->>UI: Future result with locale
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my whiskers for a clue,
I peek at the browser's little hue,
If signup's silent, I softly ask,
I tuck the locale into the task,
Then hop away, content and new 🐰🌍

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning Changes to the playground’s .gitignore and README for app-router environment settings fall outside the scope of retrieving and sending locale information during sign-up flows, as defined by the linked issue objectives. Move the playground configuration updates into a separate PR or remove them to keep this feature branch focused solely on locale retrieval and sign-up flow modifications.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title uses a clear conventional commit format and succinctly captures the primary change of adding an optional browser-derived locale to the signup flow, making it immediately understandable to reviewers scanning commit history.
Linked Issues Check ✅ Passed The implementation fully addresses USER-3606 by introducing a getBrowserLocale helper that returns the first available navigator.language or null, injecting this value only during the signup create flows, and updating all relevant resource snapshots, futures, types, and tests without affecting other flows.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups

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

@guilherme6191 guilherme6191 changed the title feat: Add optional locale frowm browser to signup flow feat(clerk-js, types): Add optional locale frowm browser to signup flow Oct 3, 2025
@guilherme6191 guilherme6191 self-assigned this Oct 3, 2025
Copy link
Member

@tmilewski tmilewski left a comment

Choose a reason for hiding this comment

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

This is looking good, but holding off on approving as we'll need to get the supporting work in.

@guilherme6191 guilherme6191 force-pushed the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch from 5f02d05 to 1cf759a Compare October 6, 2025 21:18
@guilherme6191 guilherme6191 changed the title feat(clerk-js, types): Add optional locale frowm browser to signup flow feat(clerk-js, types): Add optional locale from browser to signup flow Oct 7, 2025
@guilherme6191 guilherme6191 force-pushed the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch from 1cf759a to c3c3ba3 Compare October 8, 2025 19:45
@guilherme6191 guilherme6191 marked this pull request as ready for review October 8, 2025 20:00
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/clerk-js/src/core/resources/SignUp.ts (2)

466-491: Missing locale deserialization in fromJSON.

The fromJSON method does not populate this.locale from the API response data. This means the locale value will be lost when the SignUp object is reconstructed from JSON (e.g., after page refresh or state rehydration).

Add locale deserialization:

 protected fromJSON(data: SignUpJSON | SignUpJSONSnapshot | null): this {
   if (data) {
     this.id = data.id;
     this.status = data.status;
     this.requiredFields = data.required_fields;
     this.optionalFields = data.optional_fields;
     this.missingFields = data.missing_fields;
     this.unverifiedFields = data.unverified_fields;
     this.verifications = new SignUpVerifications(data.verifications);
     this.username = data.username;
     this.firstName = data.first_name;
     this.lastName = data.last_name;
     this.emailAddress = data.email_address;
     this.phoneNumber = data.phone_number;
     this.hasPassword = data.has_password;
     this.unsafeMetadata = data.unsafe_metadata;
     this.createdSessionId = data.created_session_id;
     this.createdUserId = data.created_user_id;
     this.abandonAt = data.abandon_at;
     this.web3wallet = data.web3_wallet;
     this.legalAcceptedAt = data.legal_accepted_at;
+    this.locale = data.locale;
   }

   eventBus.emit('resource:update', { resource: this });
   return this;
 }

493-518: Missing locale serialization in __internal_toSnapshot.

The __internal_toSnapshot method does not include the locale field in the returned snapshot. This will prevent the locale from being persisted in state management and cause data loss during serialization.

Add locale to the snapshot:

 public __internal_toSnapshot(): SignUpJSONSnapshot {
   return {
     object: 'sign_up',
     id: this.id || '',
     status: this.status || null,
     required_fields: this.requiredFields,
     optional_fields: this.optionalFields,
     missing_fields: this.missingFields,
     unverified_fields: this.unverifiedFields,
     verifications: this.verifications.__internal_toSnapshot(),
     username: this.username,
     first_name: this.firstName,
     last_name: this.lastName,
     email_address: this.emailAddress,
     phone_number: this.phoneNumber,
     has_password: this.hasPassword,
     unsafe_metadata: this.unsafeMetadata,
     created_session_id: this.createdSessionId,
     created_user_id: this.createdUserId,
     abandon_at: this.abandonAt,
     web3_wallet: this.web3wallet,
     legal_accepted_at: this.legalAcceptedAt,
+    locale: this.locale,
     external_account: this.externalAccount,
     external_account_strategy: this.externalAccount?.strategy,
   };
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7edaa7a and c3c3ba3.

📒 Files selected for processing (9)
  • packages/clerk-js/src/core/resources/SignUp.ts (4 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/clerk-js/src/utils/index.ts (1 hunks)
  • packages/clerk-js/src/utils/locale.ts (1 hunks)
  • packages/types/src/signUp.ts (1 hunks)
  • packages/types/src/signUpCommon.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (1 hunks)
  • playground/app-router/.gitignore (1 hunks)
  • playground/app-router/README.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • playground/app-router/README.md
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
packages/**/index.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use tree-shaking friendly exports

Files:

  • packages/clerk-js/src/utils/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/utils/index.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUpCommon.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/__tests__/locale.test.ts
  • packages/types/src/signUp.ts
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

Use index.ts files for clean imports but avoid deep barrel exports

Avoid barrel files (index.ts re-exports) as they can cause circular dependencies

Files:

  • packages/clerk-js/src/utils/index.ts
playground/**

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Development and testing applications should be placed under the playground/ directory

Files:

  • playground/app-router/README.md
playground/**/*

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Development and testing applications must be located in the 'playground/' directory.

Files:

  • playground/app-router/README.md
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
🧬 Code graph analysis (3)
packages/clerk-js/src/utils/locale.ts (1)
packages/clerk-js/src/utils/runtime.ts (1)
  • inBrowser (1-3)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-25)
packages/clerk-js/src/utils/__tests__/locale.test.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-25)
🔇 Additional comments (10)
playground/app-router/.gitignore (1)

28-28: LGTM!

The updated .env* pattern properly catches all environment file variants, and ignoring the /.clerk/ directory is appropriate for protecting configuration that may contain secrets.

Also applies to: 36-38

playground/app-router/README.md (1)

15-15: Verify the port change is intentional.

The port has been updated from 3000 to 4011 in the documentation. This change appears unrelated to the locale feature being added in this PR.

Is this port change intentional for the playground configuration, or was it inadvertently included?

Also applies to: 19-19

packages/types/src/signUpFuture.ts (1)

6-12: LGTM!

The optional locale field is correctly added to SignUpFutureAdditionalParams and will propagate through SignUpFutureCreateParams and SignUpFutureUpdateParams as intended.

packages/clerk-js/src/utils/index.ts (1)

26-26: LGTM!

The locale utilities are properly exported following the existing barrel export pattern.

packages/types/src/signUpCommon.ts (1)

103-103: LGTM!

The locale parameter is correctly added as an optional field to SignUpCreateParams, consistent with the existing parameter structure.

packages/types/src/signUp.ts (1)

63-63: LGTM!

The locale field is correctly added to the SignUpResource interface with the appropriate string | null type, consistent with other nullable fields like emailAddress and phoneNumber.

packages/clerk-js/src/core/resources/SignUp.ts (3)

49-49: LGTM!

The import of getBrowserLocale and the initialization of the locale property are correct.

Also applies to: 99-99


159-162: LGTM!

The browser locale is correctly injected when not explicitly provided in the create parameters.


687-689: LGTM!

The locale injection in SignUpFuture.create() correctly mirrors the implementation in the main create() method.

packages/clerk-js/src/utils/locale.ts (1)

1-25: LGTM! Clean and defensive implementation.

The function correctly handles all edge cases:

  • Returns null when not in a browser environment
  • Safely accesses navigator.language with optional chaining
  • Validates the locale is a non-empty string
  • Returns the locale in BCP 47 format when valid

The JSDoc is comprehensive, the return type is explicit, and the implementation follows TypeScript best practices.

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: 0

🧹 Nitpick comments (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)

159-166: Locale injection logic is correct.

The implementation properly retrieves the browser locale when not explicitly provided. The getBrowserLocale() utility handles validation (non-empty string check) and returns null when unavailable, which is appropriate.

Optional: Consider unifying locale injection logic.

There's a minor difference in how locale is injected here versus in SignUpFuture.create (lines 696-698):

  • This approach: Only adds locale if browserLocale is truthy
  • SignUpFuture approach: Uses params.locale || getBrowserLocale() || undefined

Consider extracting this into a shared helper function to ensure consistent behavior across both paths:

// In utils or as a private method
const getLocaleForSignUp = (providedLocale?: string | null): string | undefined => {
  if (providedLocale) return providedLocale;
  const browserLocale = getBrowserLocale();
  return browserLocale || undefined;
};

Then use it in both places:

finalParams.locale = getLocaleForSignUp(finalParams.locale);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c3c3ba3 and bb5bdc9.

📒 Files selected for processing (5)
  • packages/clerk-js/src/core/resources/SignUp.ts (7 hunks)
  • packages/clerk-js/src/test/core-fixtures.ts (1 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/types/src/json.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/utils/tests/locale.test.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (8)
packages/types/src/json.ts (1)

139-139: LGTM!

The addition of locale: string | null to the SignUpJSON interface is correct and aligns with the PR objectives. The nullable type maintains backwards compatibility, and the placement alongside other metadata fields is logical.

packages/clerk-js/src/test/core-fixtures.ts (1)

234-235: LGTM!

The test fixture correctly includes the new legal_accepted_at and locale fields, maintaining consistency with the updated SignUpJSON interface.

packages/clerk-js/src/core/resources/SignUp.ts (6)

49-49: LGTM!

Import of getBrowserLocale utility is appropriate for the locale injection functionality.


99-99: LGTM!

The locale property is correctly added to the SignUp class with the appropriate type.


490-490: LGTM!

Correctly populates the locale field from JSON data in the deserialization path.


519-519: LGTM!

The locale field is correctly included in the snapshot serialization, maintaining consistency with other fields.


635-637: LGTM!

The locale getter properly exposes the field through the SignUpFuture wrapper.


696-698: Locale injection works correctly.

The logic appropriately defaults to browser locale when not provided. See the earlier comment on lines 159-166 regarding optional unification of this logic.

@guilherme6191 guilherme6191 force-pushed the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch from bb5bdc9 to 9dc724c Compare October 8, 2025 20:14
Copy link

pkg-pr-new bot commented Oct 8, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6915

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6915

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6915

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6915

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6915

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6915

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6915

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6915

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6915

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6915

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6915

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6915

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6915

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6915

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6915

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6915

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6915

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6915

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6915

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6915

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6915

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6915

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6915

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6915

commit: e07029d

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: 0

🧹 Nitpick comments (1)
packages/clerk-js/src/utils/__tests__/locale.test.ts (1)

10-32: Consider adding edge case tests for better coverage.

The current tests cover the main scenarios well. To strengthen coverage, consider adding tests for:

  1. Whitespace-only string: The implementation checks locale.trim() === '', but there's no explicit test for strings like ' '.
  2. Non-browser environment: The implementation calls inBrowser() first, but this path isn't tested (may require mocking inBrowser()).

Example test for whitespace-only string:

it('returns null as default when navigator.language is whitespace only', () => {
  vi.stubGlobal('navigator', { language: '   ' });

  expect(getBrowserLocale()).toBeNull();
});
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bb5bdc9 and 9dc724c.

📒 Files selected for processing (6)
  • packages/clerk-js/src/core/resources/SignUp.ts (7 hunks)
  • packages/clerk-js/src/test/core-fixtures.ts (1 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/clerk-js/src/utils/locale.ts (1 hunks)
  • packages/types/src/json.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/types/src/json.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpFuture.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/test/core-fixtures.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/utils/__tests__/locale.test.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/utils/__tests__/locale.test.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/clerk-js/src/utils/__tests__/locale.test.ts (1)

5-8: Cleanup properly implemented.

The afterEach hook using vi.unstubAllGlobals() correctly addresses the previous review concern about restoring global state. This ensures test isolation and prevents pollution between tests.

@guilherme6191 guilherme6191 force-pushed the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch from 9dc724c to 93c8d23 Compare October 8, 2025 20:40
coderabbitai[bot]

This comment was marked as resolved.

Copy link
Member

@tmilewski tmilewski left a comment

Choose a reason for hiding this comment

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

One small suggestion, just to be safe. Let's add a changeset and 🚀!

}

// Get locale from the browser
const locale = navigator?.language;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const locale = navigator?.language;
try {
const locale = navigator?.language;
} catch {
return DEFAULT_LOCALE;
}

We might as well play it safe. Not too sure about Browser Extensions, etc here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

first_name: signUpParams.first_name,
has_password: signUpParams.has_password,
last_name: signUpParams.last_name,
legal_accepted_at: signUpParams.legal_accepted_at,
Copy link
Member

Choose a reason for hiding this comment

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

good catch!

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: 0

🧹 Nitpick comments (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)

696-704: Approve with optional refactor suggestion.

The locale injection logic is correctly implemented and ensures browser locale is included when not explicitly provided.

Consider extracting the locale injection logic into a helper function to reduce duplication between SignUp.create (lines 159-165) and SignUpFuture.create (lines 696-704). This would improve maintainability if the logic needs to change in the future.

Example refactor:

function injectBrowserLocaleIfMissing<T extends { locale?: string }>(params: T): T {
  if (!params.locale) {
    const browserLocale = getBrowserLocale();
    if (browserLocale) {
      return { ...params, locale: browserLocale };
    }
  }
  return params;
}

Then use it as:

// In SignUp.create
let finalParams = injectBrowserLocaleIfMissing(params);

// In SignUpFuture.create
const createParams = injectBrowserLocaleIfMissing(params);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b247d8a and 07734c4.

📒 Files selected for processing (13)
  • .changeset/funny-memes-crash.md (1 hunks)
  • packages/clerk-js/src/core/resources/SignUp.ts (7 hunks)
  • packages/clerk-js/src/test/core-fixtures.ts (1 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/clerk-js/src/utils/index.ts (1 hunks)
  • packages/clerk-js/src/utils/locale.ts (1 hunks)
  • packages/react/src/stateProxy.ts (1 hunks)
  • packages/types/src/json.ts (1 hunks)
  • packages/types/src/signUp.ts (1 hunks)
  • packages/types/src/signUpCommon.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (2 hunks)
  • playground/app-router/.gitignore (1 hunks)
  • playground/app-router/README.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/clerk-js/src/test/core-fixtures.ts
  • packages/types/src/signUpFuture.ts
  • packages/types/src/signUpCommon.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/types/src/signUp.ts
  • packages/clerk-js/src/utils/tests/locale.test.ts
  • packages/clerk-js/src/utils/index.ts
  • playground/app-router/.gitignore
  • packages/types/src/json.ts
🧰 Additional context used
📓 Path-based instructions (9)
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/funny-memes-crash.md
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • playground/app-router/README.md
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/react/src/stateProxy.ts
playground/**

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Development and testing applications should be placed under the playground/ directory

Files:

  • playground/app-router/README.md
playground/**/*

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Development and testing applications must be located in the 'playground/' directory.

Files:

  • playground/app-router/README.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/react/src/stateProxy.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/react/src/stateProxy.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/react/src/stateProxy.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/react/src/stateProxy.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/react/src/stateProxy.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (9)
packages/react/src/stateProxy.ts (1)

197-199: LGTM!

The locale getter implementation follows the established pattern used for other getters in the signUp proxy and correctly defaults to null when the client is not ready.

playground/app-router/README.md (1)

15-15: Verify if port change was intentional.

The port number has been changed from 3000 to 4011 in the playground README, but this change doesn't appear related to the locale feature described in the PR objectives. Please confirm whether this was an intentional change or if it should be reverted.

Also applies to: 19-19

.changeset/funny-memes-crash.md (1)

1-7: LGTM!

The changeset is properly formatted with appropriate minor version bumps for all affected packages and a clear description of the new feature.

packages/clerk-js/src/core/resources/SignUp.ts (6)

49-49: LGTM!

The getBrowserLocale import is correctly added and maintains alphabetical ordering in the import list.


99-99: LGTM!

The locale field declaration is properly typed and initialized, following the established pattern for other optional fields in the SignUp class.


159-165: LGTM!

The locale injection logic correctly:

  • Only injects when locale is not provided by the caller
  • Uses the getBrowserLocale() utility to retrieve the browser's locale
  • Handles null/empty values appropriately with the truthy check
  • Is positioned before captcha logic to ensure locale is included in the API payload

490-490: LGTM!

The locale deserialization from JSON is correctly implemented and positioned consistently with the field declaration order.


519-519: LGTM!

The locale field is correctly included in the snapshot serialization, maintaining consistency with the class field structure.


635-637: LGTM!

The locale getter in SignUpFuture correctly proxies to the underlying SignUp resource, following the established pattern for other getters.

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 (1)
packages/types/src/signUp.ts (1)

63-63: Add JSDoc for the new public locale field.

Briefly document format (BCP 47), examples, and default (null when undetermined), per public API guidelines.

As per coding guidelines, consider:

   legalAcceptedAt: number | null;
-  locale: string | null;
+  /**
+   * Preferred locale for this sign-up as a BCP 47 tag (e.g., "en-US").
+   * Null when the browser locale is unavailable or cannot be determined.
+   */
+  locale: string | null;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b247d8a and 2fb887c.

📒 Files selected for processing (12)
  • packages/clerk-js/src/core/resources/SignUp.ts (7 hunks)
  • packages/clerk-js/src/test/core-fixtures.ts (1 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/clerk-js/src/utils/index.ts (1 hunks)
  • packages/clerk-js/src/utils/locale.ts (1 hunks)
  • packages/react/src/stateProxy.ts (1 hunks)
  • packages/types/src/json.ts (1 hunks)
  • packages/types/src/signUp.ts (1 hunks)
  • packages/types/src/signUpCommon.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (2 hunks)
  • playground/app-router/.gitignore (1 hunks)
  • playground/app-router/README.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/types/src/signUpCommon.ts
  • packages/react/src/stateProxy.ts
  • packages/types/src/signUpFuture.ts
  • packages/types/src/json.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • playground/app-router/.gitignore
  • playground/app-router/README.md
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/utils/tests/locale.test.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/index.ts
  • packages/types/src/signUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/index.ts
  • packages/types/src/signUp.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/index.ts
  • packages/types/src/signUp.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/index.ts
  • packages/types/src/signUp.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/index.ts
  • packages/types/src/signUp.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/clerk-js/src/utils/index.ts
  • packages/types/src/signUp.ts
packages/**/index.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use tree-shaking friendly exports

Files:

  • packages/clerk-js/src/utils/index.ts
**/index.ts

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

Use index.ts files for clean imports but avoid deep barrel exports

Avoid barrel files (index.ts re-exports) as they can cause circular dependencies

Files:

  • packages/clerk-js/src/utils/index.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (7)
packages/clerk-js/src/utils/index.ts (1)

18-18: LGTM: exposing locale utilities via utils index is fine.

Consistent with existing exports; tree-shaking remains intact.

packages/clerk-js/src/core/resources/SignUp.ts (6)

49-49: LGTM: importing getBrowserLocale.

No concerns.


99-99: LGTM: new runtime field locale added.

Matches types; deserialization/serialization present below.


490-490: LGTM: deserializing locale from JSON.

Consistent with types and class shape.


519-519: LGTM: locale included in snapshot.

Keeps state consistent across reloads.


635-638: LGTM: SignUpFuture.locale getter.

Exposes value to callers as expected.


159-166: getBrowserLocale correctly falls back to null when locale cannot be determined. The implementation returns DEFAULT_LOCALE (null) for non-browser or invalid locale cases, so no hard default is injected.

Likely an incorrect or invalid review comment.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
packages/clerk-js/src/core/resources/SignUp.ts (3)

712-727: Locale injection is missing in the password flow.

The password method creates a sign-up via POST but does not include locale in the request body (line 716-723). This means sign-ups created via the password strategy will not have browser locale automatically injected, creating an inconsistency with other flows.

Apply this diff to add locale injection:

       const body: Record<string, unknown> = {
         strategy: 'password',
         captchaToken,
         captchaWidgetType,
         captchaError,
         ...params,
         unsafeMetadata: params.unsafeMetadata ? normalizeUnsafeMetadata(params.unsafeMetadata) : undefined,
+        locale: params.locale ?? getBrowserLocale(),
       };

748-763: Locale injection is missing in the sendPhoneCode initial creation.

When !this.resource.id (line 751), this method creates a new sign-up via POST with only phoneNumber and captcha fields (line 755). It does not include locale, meaning phone-based sign-ups won't have browser locale automatically injected.

Apply this diff to add locale injection:

         await this.resource.__internal_basePost({
           path: this.resource.pathRoot,
-          body: { phoneNumber, captchaToken, captchaWidgetType, captchaError },
+          body: {
+            phoneNumber,
+            captchaToken,
+            captchaWidgetType,
+            captchaError,
+            locale: getBrowserLocale(),
+          },
         });

776-808: Locale injection is missing in the sso flow.

The sso method creates a sign-up via POST but does not include locale in the request body (lines 790-797). This means SSO-based sign-ups will not have browser locale automatically injected, creating an inconsistency with other flows.

Apply this diff to add locale injection:

       await this.resource.__internal_basePost({
         path: this.resource.pathRoot,
         body: {
           strategy,
           redirectUrl: SignUp.clerk.buildUrlWithAuth(redirectCallbackUrl),
           redirectUrlComplete,
           captchaToken,
           captchaWidgetType,
           captchaError,
+          locale: getBrowserLocale(),
         },
       });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2fb887c and 0699483.

📒 Files selected for processing (2)
  • .changeset/funny-memes-crash.md (1 hunks)
  • packages/clerk-js/src/core/resources/SignUp.ts (7 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/core/resources/SignUp.ts
.changeset/**

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Automated releases must use Changesets.

Files:

  • .changeset/funny-memes-crash.md
🧬 Code graph analysis (1)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (7)
.changeset/funny-memes-crash.md (1)

1-7: LGTM!

The changeset format is correct and appropriately captures the minor version updates for the three affected packages. The description clearly summarizes the feature addition.

packages/clerk-js/src/core/resources/SignUp.ts (6)

49-49: LGTM!

Import of getBrowserLocale is correctly added.


99-99: LGTM!

The locale property is correctly typed as string | null and initialized to null, matching the expected default behavior.


159-166: Locale injection is correctly implemented here.

The logic properly checks if locale is not provided by the user before falling back to browser detection. The implementation respects user-provided values and only injects browser locale when necessary.

However, verify that similar locale injection is applied consistently across all sign-up creation paths (see related comment on lines 712-727, 748-763, and 776-808).


490-490: LGTM!

Deserialization of locale from JSON is correct.


519-519: LGTM!

Serialization of locale to snapshot is correct.


635-637: LGTM!

The locale getter correctly proxies to the underlying SignUp resource.

captchaError,
...params,
unsafeMetadata: params.unsafeMetadata ? normalizeUnsafeMetadata(params.unsafeMetadata) : undefined,
locale: params.locale ?? getBrowserLocale(),
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 9, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Locale injection in _create is correct.

The nullish coalescing operator properly handles the fallback: user-provided locale takes precedence, then browser locale, and finally null (when browser detection fails).

However, ensure that the password, sendPhoneCode (when !id), and sso methods also inject locale into their request bodies to maintain consistency across all sign-up creation flows. Previous review comments flagged this gap.


🏁 Script executed:

#!/bin/bash
# Verify locale injection in all sign-up creation POST requests
rg -nC3 "__internal_basePost.*pathRoot" packages/clerk-js/src/core/resources/SignUp.ts | grep -A10 "body:"

Length of output: 0


🏁 Script executed:

#!/bin/bash
rg -n "__internal_basePost" -C5 packages/clerk-js/src/core/resources/SignUp.ts

Length of output: 4285


Inject locale into sendPhoneCode and SSO flows

sendPhoneCode’s initial POST (when !id) and its prepare-verification branch, as well as the SSO prepare POST, currently omit locale: params.locale ?? getBrowserLocale(). Add this fallback to their request bodies.

🤖 Prompt for AI Agents
In packages/clerk-js/src/core/resources/SignUp.ts around line 689, the
sendPhoneCode initial POST when !id, its prepare-verification branch, and the
SSO prepare POST are missing the locale field; update each request body to
include locale: params.locale ?? getBrowserLocale() so the locale fallback is
sent with the request, adding that expression into the respective body objects
for those three branches.

✅ Addressed in commits 65b7cc7 to e07029d

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we need that now especially because that's for the FutureSignUp logic with signal. That's experimental and I'm unsure we need to add more surface and update it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@guilherme6191, understood! That makes sense—since SignUpFuture is experimental, it's reasonable to keep the scope focused for now and avoid expanding the surface area unnecessarily. The current implementation in _create covers the main use case. 👍

@guilherme6191 guilherme6191 force-pushed the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch from 0699483 to e07029d Compare October 9, 2025 16:52
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: 0

🧹 Nitpick comments (2)
packages/clerk-js/src/utils/locale.ts (1)

1-28: LGTM!

The getBrowserLocale() implementation is well-guarded with:

  • SSR protection via inBrowser()
  • Try-catch for browser extension edge cases
  • Optional chaining on navigator?.language
  • Proper validation of the returned value

Consider whether the trim() check on line 21 is necessary. If navigator.language returns whitespace-only strings in some edge case, the trim is valuable. Otherwise, you could simplify to:

-    if (!locale || typeof locale !== 'string' || locale.trim() === '') {
+    if (!locale || typeof locale !== 'string' || locale === '') {
       return DEFAULT_LOCALE;
     }

However, keeping the trim check is a safe defensive measure and doesn't introduce any issues.

packages/clerk-js/src/core/resources/SignUp.ts (1)

159-165: Use nullish coalescing for consistency with SignUpFuture.

The locale injection uses if (!finalParams.locale) which treats null, undefined, and empty string the same. For consistency with SignUpFuture._create (line 689) which uses nullish coalescing (??), consider aligning the patterns.

Apply this diff to align with the nullish coalescing pattern:

-    // Inject browser locale if not already provided
-    if (!finalParams.locale) {
-      const browserLocale = getBrowserLocale();
-      if (browserLocale) {
-        finalParams.locale = browserLocale;
-      }
-    }
+    // Inject browser locale if not already provided
+    finalParams.locale = finalParams.locale ?? getBrowserLocale() ?? undefined;

This makes the behavior explicit: user-provided locale (including explicit null) takes precedence, then browser locale, then undefined (which gets filtered out in the request body).

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0699483 and e07029d.

📒 Files selected for processing (13)
  • .changeset/funny-memes-crash.md (1 hunks)
  • packages/clerk-js/src/core/resources/SignUp.ts (7 hunks)
  • packages/clerk-js/src/test/core-fixtures.ts (1 hunks)
  • packages/clerk-js/src/utils/__tests__/locale.test.ts (1 hunks)
  • packages/clerk-js/src/utils/index.ts (1 hunks)
  • packages/clerk-js/src/utils/locale.ts (1 hunks)
  • packages/react/src/stateProxy.ts (1 hunks)
  • packages/types/src/json.ts (1 hunks)
  • packages/types/src/signUp.ts (1 hunks)
  • packages/types/src/signUpCommon.ts (1 hunks)
  • packages/types/src/signUpFuture.ts (2 hunks)
  • playground/app-router/.gitignore (1 hunks)
  • playground/app-router/README.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/clerk-js/src/utils/tests/locale.test.ts
  • packages/types/src/signUpFuture.ts
  • packages/types/src/signUp.ts
  • packages/clerk-js/src/test/core-fixtures.ts
  • .changeset/funny-memes-crash.md
  • packages/types/src/json.ts
  • packages/clerk-js/src/utils/index.ts
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • playground/app-router/README.md
  • packages/react/src/stateProxy.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpCommon.ts
playground/**

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Development and testing applications should be placed under the playground/ directory

Files:

  • playground/app-router/README.md
playground/**/*

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Development and testing applications must be located in the 'playground/' directory.

Files:

  • playground/app-router/README.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/react/src/stateProxy.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpCommon.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/react/src/stateProxy.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpCommon.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/react/src/stateProxy.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpCommon.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/react/src/stateProxy.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpCommon.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/react/src/stateProxy.ts
  • packages/clerk-js/src/utils/locale.ts
  • packages/clerk-js/src/core/resources/SignUp.ts
  • packages/types/src/signUpCommon.ts
🧬 Code graph analysis (2)
packages/clerk-js/src/utils/locale.ts (2)
packages/clerk-js/src/utils/runtime.ts (1)
  • inBrowser (1-3)
packages/clerk-js/src/core/resources/SignUp.ts (1)
  • locale (635-637)
packages/clerk-js/src/core/resources/SignUp.ts (1)
packages/clerk-js/src/utils/locale.ts (1)
  • getBrowserLocale (11-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (11)
playground/app-router/README.md (1)

15-15: LGTM!

The localhost port references are correctly updated from 3000 to 4011, ensuring the README accurately reflects the playground application configuration.

Also applies to: 19-19

playground/app-router/.gitignore (2)

36-38: LGTM!

Adding /.clerk/ to gitignore is appropriate as this directory can contain local Clerk configuration and secrets that should not be committed.


28-28: Approve updated .gitignore No .env.example, .env.template, or .env.sample files exist in playground/app-router; the .env* pattern safely ignores only environment files.

packages/types/src/signUpCommon.ts (1)

103-103: LGTM!

The optional locale field addition to SignUpCreateParams is correctly typed and maintains backward compatibility.

packages/react/src/stateProxy.ts (1)

197-199: LGTM!

The locale getter follows the established pattern for exposing SignUp properties through the state proxy, with an appropriate null default for SSR/unloaded states.

packages/clerk-js/src/core/resources/SignUp.ts (6)

49-49: LGTM!

The getBrowserLocale import is correctly added to support locale injection in the signup flow.


99-99: LGTM!

The locale property is properly typed as string | null and follows the naming convention of other SignUp properties.


490-490: LGTM!

The locale field is correctly deserialized from the JSON response data.


519-519: LGTM!

The locale field is correctly included in the snapshot serialization.


635-637: LGTM!

The locale getter in SignUpFuture correctly proxies to the underlying SignUp resource, maintaining consistency with other getter implementations.


689-689: LGTM!

The locale injection in SignUpFuture._create uses nullish coalescing (??) appropriately: user-provided locale takes precedence, then browser locale, then null (which is included in the request body).

@guilherme6191 guilherme6191 merged commit aa7210c into main Oct 9, 2025
42 checks passed
@guilherme6191 guilherme6191 deleted the guilherme/user-3606-retrieve-and-send-locale-information-with-sign-ups branch October 9, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants