Remix

Encrypt a .env file in Remix with the Dotenvx Node.js SDK, commit it safely, and load its secrets at runtime.

1. Install

Get the Dotenvx Node.js SDK.
$ npm install @dotenvx/dotenvx

2. Encrypt

Encrypt your .env file.

$ npx dotenvx encrypt

3. Inject

Preface Remix scripts with dotenvx run -- and read your env values in a Remix loader.
{
  "scripts": {
    "build": "dotenvx run -- remix build",
    "dev": "dotenvx run -- remix dev --manual",
    "start": "dotenvx run -- remix-serve ./build/index.js"
  }
}
import { json } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";

export async function loader() {
  return json({
    ENV: {
      HELLO: process.env.HELLO,
    },
  });
}

export default function Index() {
  const data = useLoaderData()

  return (
    <div>
      Hello {data.ENV.HELLO}.
    </div>
  );
}