Complete the code to access an environment variable in Remix.
const apiKey = process.env.[1];Environment variables are accessed using process.env followed by the exact variable name, which is usually uppercase with underscores.
Complete the code to load environment variables in a Remix loader function.
export async function loader() {
return json({ secret: process.env.[1] });
}Use the exact uppercase environment variable name to access it inside the loader function.
Fix the error in the code to correctly expose a public environment variable in Remix.
const publicUrl = process.env.[1];Remix requires public environment variables to start with PUBLIC_ and be uppercase with underscores.
Fill both blanks to create a server-only environment variable and access it safely in Remix.
if (!process.env.[1]) { throw new Error('[2] is not set'); }
Check for the presence of the server-only environment variable DATABASE_URL and throw an error if missing.
Fill all three blanks to safely expose a public environment variable in a Remix component.
export default function Config() {
const publicApi = process.env.[1];
return <div>API URL: {publicApi || '[2]'}</div>;
}
// Remember to prefix public variables with [3]Public environment variables must start with PUBLIC_. The component safely shows the variable or a fallback message.