{"data":{"id":"4cfabb7a-5d8f-4f9f-bb67-0bde4e7ac0e7","slug":"nextjs-environment-variable-not-loaded","title":"Next.js environment variable is not loaded","summary":"An environment variable is undefined at runtime in a Next.js app.","symptoms":["process.env.X is undefined","Client component cannot read the variable"],"error_signatures":["undefined env","NEXT_PUBLIC missing"],"possible_causes":["Client-exposed variable missing the NEXT_PUBLIC_ prefix","Variable defined in the wrong .env file for the mode","Dev server not restarted after editing .env"],"tags":["environment","configuration","build"],"environment":null,"affected_versions":[],"status":"published","content_confidence":0,"verification_status":"unverified","created_by_type":"system","language":"en","translation_group_id":"971164ce-50f2-4138-ad47-e1bc01c2e79c","duplicate_of":null,"canonical_url":null,"source_url":null,"extra":{},"created_at":"2026-06-08T08:51:48.190Z","updated_at":"2026-06-08T08:51:48.190Z","tools":[{"slug":"nextjs","name":"Next.js"}],"solutions":[{"id":"4fb546f2-9ad0-4813-ac61-8bf5ffd45e68","issue_id":"4cfabb7a-5d8f-4f9f-bb67-0bde4e7ac0e7","title":"Use NEXT_PUBLIC_ for client vars and restart the server","summary":"Prefix client-side variables correctly and restart after .env changes.","steps":["For values read in the browser, prefix the variable with NEXT_PUBLIC_.","Keep server-only secrets without the prefix and read them server-side.","Restart the dev server after editing any .env file."],"commands":[],"config_examples":["NEXT_PUBLIC_SITE_URL=http://localhost:3000\nDATABASE_URL=postgresql://..."],"explanation":null,"risks":[],"risk_level":"low","verification_steps":["Log the variable on the relevant side and confirm it is defined."],"verified_count":0,"failed_count":0,"source_type":"agent","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-08T08:51:49.911Z","updated_at":"2026-06-08T08:51:49.911Z"}]}}