Clerk Go SDK
The Clerk Go SDK is a wrapper over the Clerk Backend API.
Installation
If you're using Go Modules and have a go.mod
file in your project's root, you can import clerk-sdk-go
directly:
Alternatively, you can go get
the package explicitly:
Usage
For details on how to use this module, see the Go Documentation.
The Clerk Go SDK is organized using a resource-based structure similar to the Clerk Backend API. Each API supports specific operations, like Create or List. While operations for each resource vary, a similar pattern is applied throughout Clerk Go.
To execute API operations, you must configure Clerk Go with your Clerk secret key. To find your Clerk secret key:
- Navigate to the Clerk Dashboard and select your application.
- In the navigation sidebar, select API Keys.
- In the Secret Keys section, you can copy your secret key. It is the same key across all frameworks.
Depending on your use case, there are two ways to use the Clerk Go SDK: With or without a client.
For most use cases, the API without a client is a better choice. It requires a minimal setup and provides a more concise API for invoking operations.
However, if you need to operate on multiple Clerk instances from one application, or need more flexibility for tests and mocking, you can instantiate multiple API clients with different API keys.
The following examples demonstrate both approaches.
Usage without a client
If you only use one API key, you can import the packages required for the APIs you need. Then you can execute your desired request methods as functions, such as $resource$.Get()
or $resource$.Delete()
. The following example demonstrates this process:
Usage with a client
If you're working with multiple keys, it's recommended to use Clerk Go with a client. The API packages for each
resource export a Client
, which supports all the API's operations.
This way, you can create as many clients as needed, each with their own API key, as shown in the following example:
For more usage details, check out the examples or the library's README file.
Feedback
Last updated on