{"id":18934,"library":"worker-auth-providers","title":"worker-auth-providers","description":"worker-auth-providers is an open-source library providing authentication providers for Cloudflare Workers. The current version is 0.0.14-beta.10, released as a beta with irregular cadence. It supports OAuth and OTP authentication for providers like GitHub, Google, Facebook, Discord, Spotify, Twilio, Mailgun, SendGrid, and AWS SNS. Designed specifically for Cloudflare Workers, it is lightweight with minimal dependencies. Key differentiators vs. alternatives like Auth0 or Passport.js: it runs at the edge with no external server, is framework-agnostic, and uses KV storage for OTPs. Types included.","status":"active","version":"0.0.14-beta.10","language":"javascript","source_language":"en","source_url":"https://github.com/subhendukundu/worker-auth-providers","tags":["javascript","typescript"],"install":[{"cmd":"npm install worker-auth-providers","lang":"bash","label":"npm"},{"cmd":"yarn add worker-auth-providers","lang":"bash","label":"yarn"},{"cmd":"pnpm add worker-auth-providers","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; CJS require() will fail.","wrong":"const github = require('worker-auth-providers')","symbol":"github","correct":"import { github } from 'worker-auth-providers'"},{"note":"Google is a named export, not default.","wrong":"import Google from 'worker-auth-providers'","symbol":"google","correct":"import { google } from 'worker-auth-providers'"},{"note":"Available for OTP via AWS SNS.","wrong":"","symbol":"awsSNS","correct":"import { awsSNS } from 'worker-auth-providers'"}],"quickstart":{"code":"import { github, google } from 'worker-auth-providers';\n\nasync function handleRequest(request) {\n  const clientId = process.env.GITHUB_CLIENT_ID ?? '';\n  const clientSecret = process.env.GITHUB_CLIENT_SECRET ?? '';\n\n  // Redirect to GitHub OAuth\n  if (request.url.includes('/login/github')) {\n    const githubLoginUrl = await github.redirect({\n      options: { clientId },\n    });\n    return new Response(null, {\n      status: 302,\n      headers: { location: githubLoginUrl },\n    });\n  }\n\n  // Handle callback and get user\n  if (request.url.includes('/callback/github')) {\n    const url = new URL(request.url);\n    const code = url.searchParams.get('code');\n    const { user, tokens } = await github.users({\n      options: { clientSecret, clientId },\n      request,\n    });\n    return new Response(JSON.stringify({ user, tokens }), {\n      headers: { 'content-type': 'application/json' },\n    });\n  }\n\n  return new Response('Hello Worker Auth!');\n}\n\naddEventListener('fetch', event => {\n  event.respondWith(handleRequest(event.request));\n});","lang":"typescript","description":"Demonstrates GitHub OAuth login redirect and user retrieval in a Cloudflare Worker."},"warnings":[{"fix":"Pin to an exact version and update carefully.","message":"Package is pre-1.0.0 (beta) and APIs may change without notice.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Check documentation for Apple export availability.","message":"apple provider was on roadmap but not yet exported; may be added in future.","severity":"deprecated","affected_versions":">=0.0.1"},{"fix":"Bind a KV namespace to WORKER_AUTH_PROVIDERS_STORE in wrangler.toml.","message":"OTP providers (awsSNS, twilio, etc.) require a KV namespace named WORKER_AUTH_PROVIDERS_STORE for storing OTPs.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use TypeScript to validate options at compile time.","message":"Some providers (e.g., facebook, discord, spotify) may have different options shapes; check types.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure options object is passed: github.redirect({ options: { clientId: 'YOUR_CLIENT_ID' } })","cause":"clientId option not passed or undefined in redirect call.","error":"TypeError: Cannot read properties of undefined (reading 'clientId')"},{"fix":"Add kv_namespaces binding: [[kv_namespaces]] binding = \"WORKER_AUTH_PROVIDERS_STORE\" id = \"your-kv-namespace-id\"","cause":"WORKER_AUTH_PROVIDERS_STORE KV namespace not bound in wrangler.toml.","error":"Error: KV namespace not found"},{"fix":"Use import syntax or set \"type\": \"module\" in package.json.","cause":"Using CommonJS require() on ESM-only package.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}