Backend SDK functions do not throw errors when something goes wrong. Instead, they return a ClerkBackendApiResponse object, just as they would if there were no errors.
Looks like returning errors as values is something that's coming soon, which is fine, but then that probably shouldn't be what the documentation says. Tying into this, @clerk/shared is a dependency of @clerk/nextjs but it doesn't get installed alongside it. To get proper typing when catching errors, installing the shared package is necessary as the nextjs package doesn't re-export ClerkAPIResponseError.
According to this page on the backend SDK: https://clerk.com/docs/references/backend/overview
This is not the actual behavior of the SDK, which throws them due to a legacy function: https://github.com/clerk/javascript/blob/%40clerk/nextjs%405.1.5/packages/backend/src/api/request.ts#L186
Looks like returning errors as values is something that's coming soon, which is fine, but then that probably shouldn't be what the documentation says. Tying into this,
@clerk/shared
is a dependency of@clerk/nextjs
but it doesn't get installed alongside it. To get proper typing when catching errors, installing the shared package is necessary as the nextjs package doesn't re-exportClerkAPIResponseError
.