You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update missing and invalid key error messages to recommend the Clerk CLI: `npx clerk@latest init` (non-interactive, no Clerk account required) to create an application, `npx clerk@latest env pull` to fetch the keys of an existing one, and `npx clerk@latest deploy` / `npx clerk@latest env pull --instance prod` for production. This covers both the `errorThrower` messages and the errors thrown by `parsePublishableKey(key, { fatal: true })`, which previously surfaced server-side as a bare `Publishable key not valid.` The Dashboard link is kept for manual key copying.
'@clerk/test-package: The publishableKey passed to Clerk is invalid. You can get your Publishable key at https://dashboard.clerk.com/last-active?path=api-keys. (key=whatever)',
19
+
'@clerk/test-package: The publishableKey passed to Clerk is invalid (key=whatever, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:\n\n npx clerk@latest init',
20
20
);
21
21
});
22
22
23
23
it('throws the correct error message and interpolates pkg if no parameters are provided',()=>{
'Publishable key is missing. Ensure that your publishable key is correctly configured. Double-check your environment configuration for your keys, or access them here: https://dashboard.clerk.com/last-active?path=api-keys',
84
+
'Publishable key is missing. To create a Clerk application with valid keys, in your terminal run:\n\n npx clerk@latest init',
Copy file name to clipboardExpand all lines: packages/shared/src/errors/errorThrower.ts
+21-3Lines changed: 21 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,26 @@
1
1
constDefaultMessages=Object.freeze({
2
2
InvalidProxyUrlErrorMessage: `The proxyUrl passed to Clerk is invalid. The expected value for proxyUrl is an absolute URL or a relative path with a leading '/'. (key={{url}})`,
3
-
InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid. You can get your Publishable key at https://dashboard.clerk.com/last-active?path=api-keys. (key={{key}})`,
4
-
MissingPublishableKeyErrorMessage: `Missing publishableKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.`,
5
-
MissingSecretKeyErrorMessage: `Missing secretKey. You can get your key at https://dashboard.clerk.com/last-active?path=api-keys.`,
3
+
InvalidPublishableKeyErrorMessage: `The publishableKey passed to Clerk is invalid (key={{key}}, expected format: pk_test_... or pk_live_...). To create a Clerk application with valid keys, in your terminal run:
4
+
5
+
npx clerk@latest init
6
+
7
+
It creates a Clerk application and writes keys to your .env file. Requires no Clerk account or login and the command is non-interactive.
8
+
9
+
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys (\`--instance prod\` for production keys). Or copy its Publishable key from https://dashboard.clerk.com/last-active?path=api-keys.`,
10
+
MissingPublishableKeyErrorMessage: `Missing publishableKey. To set up Clerk for this project, in your terminal run:
11
+
12
+
npx clerk@latest init
13
+
14
+
It creates a Clerk application and writes keys to your .env file. Requires no Clerk account or login and the command is non-interactive.
15
+
16
+
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
17
+
MissingSecretKeyErrorMessage: `Missing secretKey. To set up Clerk for this project, in your terminal run:
18
+
19
+
npx clerk@latest init
20
+
21
+
It creates a Clerk application and writes keys to your .env file. Requires no Clerk account or login and the command is non-interactive.
22
+
23
+
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys. Or copy them from https://dashboard.clerk.com/last-active?path=api-keys. Deploy a production instance by running \`npx clerk@latest deploy\`, or \`npx clerk@latest env pull --instance prod\` to use an existing one.`,
6
24
MissingClerkProvider: `{{source}} can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider`,
Copy file name to clipboardExpand all lines: packages/shared/src/keys.ts
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,14 @@ function isValidDecodedPublishableKey(decoded: string): boolean {
98
98
returnwithoutTrailing.includes('.');
99
99
}
100
100
101
+
constfatalKeyGuidance=`To create a Clerk application with valid keys, in your terminal run:
102
+
103
+
npx clerk@latest init
104
+
105
+
It creates a Clerk application and writes keys to your .env file. Requires no Clerk account or login and the command is non-interactive.
106
+
107
+
If you have a Clerk application, run \`npx clerk@latest env pull\` to write the keys (\`--instance prod\` for production keys). Or copy them from https://dashboard.clerk.com/last-active?path=api-keys.`;
@@ -127,12 +135,10 @@ export function parsePublishableKey(
127
135
128
136
if(!key||!isPublishableKey(key)){
129
137
if(options.fatal&&!key){
130
-
thrownewError(
131
-
'Publishable key is missing. Ensure that your publishable key is correctly configured. Double-check your environment configuration for your keys, or access them here: https://dashboard.clerk.com/last-active?path=api-keys',
132
-
);
138
+
thrownewError(`Publishable key is missing. ${fatalKeyGuidance}`);
133
139
}
134
140
if(options.fatal&&!isPublishableKey(key)){
135
-
thrownewError('Publishable key not valid.');
141
+
thrownewError(`Publishable key not valid (expected format: pk_test_... or pk_live_...). ${fatalKeyGuidance}`);
136
142
}
137
143
returnnull;
138
144
}
@@ -144,14 +150,14 @@ export function parsePublishableKey(
0 commit comments