{"id":15315744,"url":"https://github.com/wobsoriano/h3-clerk","last_synced_at":"2026-04-25T17:04:06.446Z","repository":{"id":176807748,"uuid":"659575293","full_name":"wobsoriano/h3-clerk","owner":"wobsoriano","description":"Unofficial Clerk middleware for H3.","archived":false,"fork":false,"pushed_at":"2026-03-25T12:06:42.000Z","size":1197,"stargazers_count":40,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-26T15:04:53.696Z","etag":null,"topics":["authentication","h3","nuxt"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wobsoriano.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-28T06:06:10.000Z","updated_at":"2026-03-24T13:43:46.000Z","dependencies_parsed_at":"2023-06-28T12:00:31.659Z","dependency_job_id":"9a50839e-fedd-48b3-85d0-4572a7ed3176","html_url":"https://github.com/wobsoriano/h3-clerk","commit_stats":{"total_commits":298,"total_committers":6,"mean_commits":"49.666666666666664","dds":"0.13422818791946312","last_synced_commit":"854f4d385adffd4737d5480f4d5a994dcb6212d6"},"previous_names":["wobsoriano/h3-clerk"],"tags_count":75,"template":false,"template_full_name":null,"purl":"pkg:github/wobsoriano/h3-clerk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fh3-clerk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fh3-clerk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fh3-clerk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fh3-clerk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wobsoriano","download_url":"https://codeload.github.com/wobsoriano/h3-clerk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wobsoriano%2Fh3-clerk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32269467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","h3","nuxt"],"created_at":"2024-10-01T08:51:55.033Z","updated_at":"2026-04-25T17:04:06.441Z","avatar_url":"https://github.com/wobsoriano.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# h3-clerk\n\nUnofficial [Clerk](https://clerk.com/) middleware for H3.\n\n## Getting Started\n\nTo use this middleware you should first create a Clerk application and retrieve a `Secret Key` and a `Publishable Key` for your application (see [here](https://clerk.com/docs/reference/node/getting-started)) to be used as environment variables `CLERK_PUBLISHABLE_KEY` \u0026 `CLERK_SECRET_KEY`.\n\n### Installation\n\n```bash\nnpm install h3-clerk\n```\n\n## Usage\n\n```ts\nimport { H3, setResponseStatus } from 'h3';\nimport { clerkClient, clerkMiddleware, getAuth } from 'h3-clerk';\n\nconst app = new H3();\n\napp.use(clerkMiddleware());\n\napp.use('/protected-endpoint', async (event) =\u003e {\n  const { userId } = getAuth(event);\n\n  if (!userId) {\n    setResponseStatus(event, 401, 'Unauthorized');\n    return;\n  }\n\n  const user = await clerkClient.users.getUser(userId);\n\n  return { user };\n});\n```\n\n## Available methods\n\n### `clerkMiddleware()`\n\nThe `clerkMiddleware()` middleware integrates Clerk authentication into your H3 application. It is required to be set in the middleware chain before using other Clerk utilities, such as `getAuth()`.\n\n```ts\nimport { H3 } from 'h3';\nimport { clerkMiddleware } from 'h3-clerk';\n\nconst app = new H3();\n\napp.use(clerkMiddleware());\n```\n\n#### Options\n\nThe `clerkMiddleware()` helper accepts the same options as Clerk's middleware: [these options](https://clerk.com/docs/references/nextjs/clerk-middleware#clerk-middleware-options).\n\n### `getAuth()`\n\nThe `getAuth()` function retrieves authentication state from the [event object](https://h3.dev/guide/api/h3event).\n\n```ts\nimport { H3, setResponseStatus } from 'h3';\nimport { clerkMiddleware, getAuth } from 'h3-clerk';\n\nconst app = new H3();\n\napp.use(clerkMiddleware());\n\napp.use('/protected-endpoint', async (event) =\u003e {\n  const { userId, has } = getAuth(event);\n\n  if (!userId || !has({ role: 'org:admin' })) {\n    setResponseStatus(event, 401, 'Unauthorized');\n    return;\n  }\n\n  return { message: 'Hello, admin' };\n});\n```\n\n#### Using `acceptsToken` for machine auth\n\nYou can pass `acceptsToken` to `getAuth()` when you want to verify other token types (for example `api_key` and `m2m_token`).\n\n```ts\nimport { H3, setResponseStatus } from 'h3';\nimport { clerkMiddleware, getAuth } from 'h3-clerk';\n\nconst app = new H3();\n\napp.use(clerkMiddleware());\n\napp.use('/machine-endpoint', async (event) =\u003e {\n  const auth = getAuth(event, { acceptsToken: 'api_key' });\n\n  if (auth.tokenType !== 'api_key') {\n    setResponseStatus(event, 401, 'Unauthorized');\n    return;\n  }\n\n  return {\n    apiKeyId: auth.id,\n    userId: auth.userId,\n  };\n});\n```\n\nYou can also pass multiple token types:\n\n```ts\nconst auth = getAuth(event, {\n  acceptsToken: ['session_token', 'api_key', 'm2m_token'],\n});\n```\n\n### `clerkClient`\n\n[Clerk's JavaScript Backend SDK](https://clerk.com/docs/references/backend/overview) exposes Clerk's Backend API resources and low-level authentication utilities for JavaScript environments. For example, if you wanted to get a list of all users in your application, instead of creating a fetch to Clerk's `https://api.clerk.com/v1/users` endpoint, you can use the `users.getUserList()` method provided by the JavaScript Backend SDK.\n\nAll resource operations are mounted as sub-APIs on the `clerkClient` object. See the [reference documentation](https://clerk.com/docs/references/backend/overview#usage) for more information.\n\n```ts\nimport { clerkClient } from 'h3-clerk';\n\napp.use('/users', async (event) =\u003e {\n  const users = await clerkClient.users.getUserList();\n\n  return { users };\n});\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwobsoriano%2Fh3-clerk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwobsoriano%2Fh3-clerk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwobsoriano%2Fh3-clerk/lists"}