Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/hip-ideas-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/clerk-js': minor
'@clerk/clerk-react': minor
'@clerk/types': minor
---

Expose the frontend api version the clerk instance is using via `Clerk.apiVersion`.
12 changes: 11 additions & 1 deletion packages/clerk-js/src/core/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ import { memoizeListenerCallback } from '../utils/memoizeStateListenerCallback';
import { RedirectUrls } from '../utils/redirectUrls';
import { AuthCookieService } from './auth/AuthCookieService';
import { CaptchaHeartbeat } from './auth/CaptchaHeartbeat';
import { CLERK_SATELLITE_URL, CLERK_SUFFIXED_COOKIES, CLERK_SYNCED, ERROR_CODES } from './constants';
import {
CLERK_SATELLITE_URL,
CLERK_SUFFIXED_COOKIES,
CLERK_SYNCED,
ERROR_CODES,
SUPPORTED_FAPI_VERSION,
} from './constants';
import {
clerkErrorInitFailed,
clerkInvalidSignInUrlFormat,
Expand Down Expand Up @@ -275,6 +281,10 @@ export class Clerk implements ClerkInterface {
return Clerk.sdkMetadata;
}

get apiVersion(): string {
return SUPPORTED_FAPI_VERSION;
}

get loaded(): boolean {
return this.status === 'degraded' || this.status === 'ready';
}
Expand Down
4 changes: 4 additions & 0 deletions packages/react/src/isomorphicClerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ export class IsomorphicClerk implements IsomorphicLoadedClerk {
return this.clerkjs?.version;
}

get apiVersion() {
return this.clerkjs?.apiVersion;
}

get client(): ClientResource | undefined {
if (this.clerkjs) {
return this.clerkjs.client;
Expand Down
5 changes: 5 additions & 0 deletions packages/types/src/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@
*/
version: string | undefined;

/**
* The version of the Clerk Frontend API that the SDK is using.
*/
apiVersion: string | undefined;

/**
* If present, contains information about the SDK that the host application is using.
* For example, if Clerk is loaded through `@clerk/nextjs`, this would be `{ name: '@clerk/nextjs', version: '1.0.0' }`
Expand Down Expand Up @@ -1138,7 +1143,7 @@
*/
windowNavigate: (to: URL | string) => void;
},
) => Promise<unknown> | unknown;

Check warning on line 1146 in packages/types/src/clerk.ts

View workflow job for this annotation

GitHub Actions / Static analysis

'unknown' overrides all other types in this union type

export type WithoutRouting<T> = Omit<T, 'path' | 'routing'>;

Expand Down
Loading