{"record":{"id":"9db549a103e7d4e7","repo":"nextauthjs/next-auth","slug":"hasura-client-error-please-provide-an-adminsecret","errorCode":null,"errorMessage":"Hasura client error: Please provide an adminSecret","messagePattern":"Hasura client error: Please provide an adminSecret","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-hasura/src/lib/client.ts","lineNumber":27,"sourceCode":"   */\n  adminSecret: string\n}\n\nexport class HasuraClientError extends Error {\n  name = \"HasuraClientError\"\n  constructor(\n    errors: any[],\n    query: TypedDocumentString<any, any>,\n    variables: any\n  ) {\n    super(errors.map((error) => error.message).join(\"\\n\"))\n    console.error({ query, variables })\n  }\n}\n\nexport function client({ adminSecret, endpoint }: HasuraAdapterClient) {\n  if (!adminSecret)\n    throw new TypeError(\"Hasura client error: Please provide an adminSecret\")\n\n  if (!endpoint)\n    throw new TypeError(\n      \"Hasura client error: Please provide a graphql endpoint\"\n    )\n\n  return {\n    async run<\n      Q extends TypedDocumentString<any, any>,\n      T extends Q extends TypedDocumentString<infer T, any> ? T : never,\n      V extends Q extends TypedDocumentString<any, infer V> ? V : never,\n    >(query: Q, variables?: V): Promise<T> {\n      const response = await fetch(endpoint, {\n        method: \"POST\",\n        headers: {\n          \"Content-Type\": \"application/json\",\n          \"x-hasura-admin-secret\": adminSecret,\n        },","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/nextauthjs/next-auth/blob/a1a16a5a7780488c7449feece410033f445d0b31/packages/adapter-hasura/src/lib/client.ts#L9-L45","documentation":"The Hasura adapter client factory requires an adminSecret to authenticate GraphQL requests against Hasura with admin privileges. If the HasuraAdapter options omit adminSecret (or pass an empty string), client() throws this TypeError immediately at construction rather than failing later on 401 responses.","triggerScenarios":"Instantiating HasuraAdapter({ endpoint }) without adminSecret, or with adminSecret: process.env.HASURA_ADMIN_SECRET when the env var is unset/empty (e.g., missing .env file, wrong env name, not loaded).","commonSituations":"Missing HASURA_ADMIN_SECRET in the deployment environment; env vars not loaded in Next.js server runtime; renaming the env var in Hasura Cloud but not in the app; passing the secret only client-side where it's stripped.","solutions":["Pass a non-empty adminSecret to HasuraAdapter options","Verify the environment variable (e.g. HASURA_ADMIN_SECRET) is set in the runtime environment and loaded (dotenv / platform config)","Log or assert the secret's presence at startup to fail fast with a clear message","If using JWT auth instead, use an adapter/auth configuration that does not require adminSecret"],"exampleFix":"// before\nexport const adapter = HasuraAdapter({ endpoint: process.env.HASURA_ENDPOINT! })\n// after\nexport const adapter = HasuraAdapter({\n  endpoint: process.env.HASURA_ENDPOINT!,\n  adminSecret: process.env.HASURA_ADMIN_SECRET!,\n})","handlingStrategy":"validation","validationCode":"if (!process.env.HASURA_ADMIN_SECRET) {\n  throw new Error('HASURA_ADMIN_SECRET is not set')\n}\nconst adapter = HasuraAdapter({\n  endpoint: process.env.HASURA_ENDPOINT!,\n  adminSecret: process.env.HASURA_ADMIN_SECRET,\n})","typeGuard":"function hasHasuraConfig(o: any): o is { adminSecret: string; endpoint: string } {\n  return typeof o?.adminSecret === 'string' && o.adminSecret.length > 0\n}","tryCatchPattern":"try {\n  const adapter = HasuraAdapter({ adminSecret: process.env.HASURA_ADMIN_SECRET!, endpoint })\n} catch (e) {\n  if (e instanceof TypeError && e.message.includes('adminSecret')) {\n    console.error('Set HASURA_ADMIN_SECRET in the environment')\n  } else throw e\n}","preventionTips":["Assert required env vars at startup (fail fast)","Keep .env files out of deploys but mirror vars in platform settings","Use consistent env var names across environments","Never read the secret client-side"],"tags":["hasura","config","missing-env-var","authentication"],"backgroundTag":"missing-env-var","analyzedSha":"a1a16a5a7780488c7449feece410033f445d0b31","analyzedAt":"2026-08-28T21:52:38.200Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}