{"data":{"id":"1a3c93a4-fba8-4cd5-bdf7-c00279bfec2c","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":"51f5ba85-cc54-4abf-b5a6-35b1a7226821","duplicate_of":null,"canonical_url":null,"source_url":null,"extra":{},"created_at":"2026-06-16T08:39:11.103Z","updated_at":"2026-06-16T08:39:11.103Z","tools":[{"slug":"nextjs","name":"Next.js"}],"solutions":[{"id":"5a875c7e-45bf-4fae-ac4f-07f7212881bb","issue_id":"1a3c93a4-fba8-4cd5-bdf7-c00279bfec2c","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-16T08:39:11.424Z","updated_at":"2026-06-16T08:39:11.424Z"}]}}