Configure a consistent CRX ID for your Chrome Extension
Chrome Extensions have a unique CRX ID that rotates by default, which can cause errors with the Clerk integration. This guide demonstrates how to configure a consistent CRX ID so that your extension will have a stable, unchanging key. This guide assumes you are using the Plasmo framework. If you need help applying these concepts to another framework, contact support.
There are two ways to configure a consistent CRX ID:
For a new extension
To configure a consistent CRX ID for a new extension, follow these steps:
Generate your keypairs
- Visit Plasmo Itero's Generate Keypairs tool.
- Select Generate KeyPairs.
- Save the Private Key somewhere secure in case you need it in the future. Save the Public Key and the CRX ID for the next steps.
Create an .env.chrome
file to store your public key
Create an .env.chrome
file and add your public key to it, as shown in the following example:
Edit your package.json
to use the new public key
Plasmo uses the package.json
to generate a manifest.json
on build, and allows for the use of environment variables in package.json
.
In your package.json
, in the manifest
object:
- Add
"key": "$CRX_PUBLIC_KEY"
. - Set the
permissions
array to include"cookies"
and"storage"
. - Set/update the
host_permissions
array to include"http://localhost/*"
and"$CLERK_FRONTEND_API/*"
.
Verify the CRX ID
- Ensure that the development build is updated by running
pnpm dev
. - Open Chrome or a Chromium-based browser and navigate to
chrome://extensions
. - Remove and re-install the extension. To re-install, in the top-left, select Load unpacked. Navigate to where your project is located and select the
build/chrome-mv3-dev
folder. Then select Select. Your extension will now be loaded and shown in the list of extensions. - Confirm that the ID shown in your extension matches the CRX ID you saved earlier.
For an extension uploaded to the Chrome Developer Dashboard
If you have already uploaded a version of your extension to the Chrome Developer Dashboard, follow these steps to configure your extension.
Copy the public key
- In the Chrome Developer Dashboard, select your project.
- In the navigation sidebar, select Package.
- Select View public key. A modal will open with your public key.
- Copy the string between
-----BEGIN PUBLIC KEY-----
and-----END PUBLIC KEY-----
.
Create an .env.chrome
file to store your public key
Create an .env.chrome
file and add your public key to it, as shown in the following example:
Edit your package.json
to use the new public key
Plasmo uses the package.json
to generate a manifest.json
on build, and allows for the use of environment variables in package.json
.
In your package.json
, in the manifest
object:
- Add
"key": "$CRX_PUBLIC_KEY"
. - Set the
permissions
array to include"cookies"
and"storage"
. - Set/update the
host_permissions
array to include"http://localhost/*"
and"$CLERK_FRONTEND_API/*"
.
Validate the Extension ID
Verify that your extension has a consistent CRX ID by following these steps:
- At the top-left of the Chrome Developer Dashboard, your extension ID will be displayed below the name of your extension.
- In a separate tab, open Chrome or a Chromium-based browser and navigate to
chrome://extensions
. - Locate your extension in the list of extensions. Confirm that the ID shown in your extension matches the ID displayed in the Chrome Developer Dashboard.
Feedback
Last updated on