Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🔥 Remove next-runtime-env package (#2098)

Luke Vellad0bcd2dc8895
diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile
index a6e7d3be1..9298cf95d 100644
--- a/apps/web/Dockerfile
+++ b/apps/web/Dockerfile
@@ -70,7 +70,7 @@ COPY --from=installer /root/.cache/node/corepack/ /app/.cache/node/corepack/
# Copy app files
COPY --from=builder /app/scripts/docker-start.sh ./
COPY --from=builder /app/packages/database/prisma ./prisma
-COPY --from=installer /app/apps/web/next.config.js .
+COPY --from=installer /app/apps/web/next.config.ts .
COPY --from=installer /app/apps/web/package.json .
# Copy Next.js standalone output
diff --git a/apps/web/package.json b/apps/web/package.json
index 4ce75964c..6f483b087 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -46,7 +46,7 @@
"@scalar/hono-api-reference": "^0.9.30",
"@sentry/nextjs": "^9.14.0",
"@svgr/webpack": "^8.1.0",
- "@t3-oss/env-nextjs": "^0.13.8",
+ "@t3-oss/env-nextjs": "^0.13.10",
"@tailwindcss/postcss": "^4.1.18",
"@tanstack/react-query": "^5.90.12",
"@tanstack/react-query-devtools": "^5.91.1",
@@ -87,7 +87,6 @@
"nanoid": "^5.0.9",
"next": "^15.5.9",
"next-auth": "^5.0.0-beta.25",
- "next-runtime-env": "^3.3.0",
"next-safe-action": "^8.0.7",
"php-serialize": "^4.1.1",
"postcss": "^8.5.6",
diff --git a/apps/web/src/app/[locale]/layout.tsx b/apps/web/src/app/[locale]/layout.tsx
index 5e1f79650..f9ff26aab 100644
--- a/apps/web/src/app/[locale]/layout.tsx
+++ b/apps/web/src/app/[locale]/layout.tsx
@@ -6,7 +6,6 @@ import { TooltipProvider } from "@rallly/ui/tooltip";
import { domAnimation, LazyMotion } from "motion/react";
import type { Metadata, Viewport } from "next";
import { Inter } from "next/font/google";
-import { PublicEnvScript } from "next-runtime-env";
import type React from "react";
import { TimeZoneChangeDetector } from "@/app/[locale]/timezone-change-detector";
import type { Params } from "@/app/[locale]/types";
@@ -90,9 +89,6 @@ export default async function Root({
: undefined
}
>
- <head>
- <PublicEnvScript />
- </head>
<body>
<ThemeProvider>
<FeatureFlagsProvider value={featureFlagConfig}>
diff --git a/apps/web/src/app/api/private/[...route]/route.test.ts b/apps/web/src/app/api/private/[...route]/route.test.ts
index ff127b383..14e3f31f9 100644
--- a/apps/web/src/app/api/private/[...route]/route.test.ts
+++ b/apps/web/src/app/api/private/[...route]/route.test.ts
@@ -32,7 +32,7 @@ vi.mock("@vercel/functions", () => ({
}));
vi.mock("@/lib/kv", () => ({
- isKvEnabled: false,
+ isKvEnabled: () => false,
kv: null,
}));
diff --git a/apps/web/src/app/api/private/[...route]/route.ts b/apps/web/src/app/api/private/[...route]/route.ts
index 081ef03b5..31ac93dc9 100644
--- a/apps/web/src/app/api/private/[...route]/route.ts
+++ b/apps/web/src/app/api/private/[...route]/route.ts
@@ -79,7 +79,7 @@ app.post(
const { apiKeyId } = c.get("apiAuth");
return `private-api:polls-create:${apiKeyId}`;
},
- store: isKvEnabled ? new RedisStore({ client: kv }) : undefined,
+ store: isKvEnabled() ? new RedisStore({ client: kv }) : undefined,
}),
describeRoute({
tags: ["Polls"],
diff --git a/apps/web/src/env.ts b/apps/web/src/env.ts
index 08efe1a29..cd6b5ffb7 100644
--- a/apps/web/src/env.ts
+++ b/apps/web/src/env.ts
@@ -1,5 +1,4 @@
import { createEnv } from "@t3-oss/env-nextjs";
-import { env as runtimeEnv } from "next-runtime-env";
import { z } from "zod";
const vercelUrl = process.env.NEXT_PUBLIC_VERCEL_URL;
@@ -119,6 +118,12 @@ export const env = createEnv({
*/
LOGO_URL: z.url().optional(),
LOGO_ICON_URL: z.url().optional(),
+ /**
+ *
+ */
+ KV_REST_API_URL: z.url().optional(),
+ KV_REST_API_TOKEN: z.string().optional(),
+ KV_URL: z.url().optional(),
},
/*
* Environment variables available on the client (and server).
@@ -170,11 +175,11 @@ export const env = createEnv({
S3_SECRET_ACCESS_KEY: process.env.S3_SECRET_ACCESS_KEY,
S3_REGION: process.env.S3_REGION,
NEXT_PUBLIC_BASE_URL:
- runtimeEnv("NEXT_PUBLIC_BASE_URL") ??
+ process.env.NEXT_PUBLIC_BASE_URL ??
(vercelUrl ? `https://${vercelUrl}` : undefined),
- NEXT_PUBLIC_POSTHOG_API_KEY: runtimeEnv("NEXT_PUBLIC_POSTHOG_API_KEY"),
- NEXT_PUBLIC_POSTHOG_API_HOST: runtimeEnv("NEXT_PUBLIC_POSTHOG_API_HOST"),
- NEXT_PUBLIC_SELF_HOSTED: runtimeEnv("NEXT_PUBLIC_SELF_HOSTED"),
+ NEXT_PUBLIC_POSTHOG_API_KEY: process.env.NEXT_PUBLIC_POSTHOG_API_KEY,
+ NEXT_PUBLIC_POSTHOG_API_HOST: process.env.NEXT_PUBLIC_POSTHOG_API_HOST,
+ NEXT_PUBLIC_SELF_HOSTED: process.env.NEXT_PUBLIC_SELF_HOSTED,
SUPPORT_EMAIL: process.env.SUPPORT_EMAIL,
NOREPLY_EMAIL: process.env.NOREPLY_EMAIL,
NOREPLY_EMAIL_NAME: process.env.NOREPLY_EMAIL_NAME,
@@ -191,6 +196,9 @@ export const env = createEnv({
LOGO_URL: process.env.LOGO_URL,
LOGO_ICON_URL: process.env.LOGO_ICON_URL,
APP_NAME: process.env.APP_NAME,
+ KV_REST_API_URL: process.env.KV_REST_API_URL,
+ KV_REST_API_TOKEN: process.env.KV_REST_API_TOKEN,
+ KV_URL: process.env.KV_URL,
},
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
});
diff --git a/apps/web/src/lib/auth-client.ts b/apps/web/src/lib/auth-client.ts
index 1daf236cd..ae5194750 100644
--- a/apps/web/src/lib/auth-client.ts
+++ b/apps/web/src/lib/auth-client.ts
@@ -1,3 +1,4 @@
+import { absoluteUrl } from "@rallly/utils/absolute-url";
import {
anonymousClient,
emailOTPClient,
@@ -7,11 +8,10 @@ import {
} from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import { signOut as nextAuthSignOut } from "next-auth/react";
-import { env } from "@/env";
import type { Auth } from "@/lib/auth";
export const authClient = createAuthClient({
- baseURL: `${env.NEXT_PUBLIC_BASE_URL}/api/better-auth`,
+ baseURL: absoluteUrl("/api/better-auth"),
plugins: [
inferAdditionalFields<Auth>(),
emailOTPClient(),
diff --git a/apps/web/src/lib/auth.ts b/apps/web/src/lib/auth.ts
index f2f30d5b3..892f4a9ac 100644
--- a/apps/web/src/lib/auth.ts
+++ b/apps/web/src/lib/auth.ts
@@ -187,7 +187,7 @@ export const authLib = betterAuth({
},
},
},
- secondaryStorage: isKvEnabled
+ secondaryStorage: isKvEnabled()
? {
set: async (key: string, value: string, ttl?: number) => {
if (ttl) {
@@ -207,7 +207,7 @@ export const authLib = betterAuth({
}
: undefined,
rateLimit: {
- storage: isKvEnabled ? "secondary-storage" : "memory",
+ storage: isKvEnabled() ? "secondary-storage" : "memory",
},
account: {
fields: {
diff --git a/apps/web/src/lib/kv.ts b/apps/web/src/lib/kv.ts
index 7df75eb64..0dbcd7af3 100644
--- a/apps/web/src/lib/kv.ts
+++ b/apps/web/src/lib/kv.ts
@@ -1,5 +1,6 @@
import { kv } from "@vercel/kv";
+import { env } from "@/env";
-const isKvEnabled = !!process.env.KV_REST_API_URL;
+const isKvEnabled = () => !!env.KV_REST_API_URL;
export { kv, isKvEnabled };
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e71df721a..ef53a8535 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -80,7 +80,7 @@ importers:
version: 8.1.0([email protected])
'@vercel/analytics':
specifier: ^1.5.0
dayjs:
specifier: ^1.11.13
version: 1.11.13
@@ -119,7 +119,7 @@ importers:
next-seo:
specifier: ^6.1.0
react:
specifier: ^19.1.4
version: 19.2.1
@@ -257,8 +257,8 @@ importers:
specifier: ^8.1.0
version: 8.1.0([email protected])
'@t3-oss/env-nextjs':
- specifier: ^0.13.8
+ specifier: ^0.13.10
'@tailwindcss/postcss':
specifier: ^4.1.18
version: 4.1.18
@@ -379,9 +379,6 @@ importers:
next-auth:
specifier: ^5.0.0-beta.25
- next-runtime-env:
- specifier: ^3.3.0
next-safe-action:
specifier: ^8.0.7
@@ -4568,13 +4565,13 @@ packages:
resolution: {integrity: sha512-+PmQX0PiAYPMeVYe237LJAYvOMYW1j2rH5YROyS3b4CTVJum34HfRvKvAzozHAQG0TnHNdUfY9nCeUyRAs//cw==}
engines: {node: '>=14.16'}
- '@t3-oss/[email protected]':
- resolution: {integrity: sha512-L1inmpzLQyYu4+Q1DyrXsGJYCXbtXjC4cICw1uAKv0ppYPQv656lhZPU91Qd1VS6SO/bou1/q5ufVzBGbNsUpw==}
+ '@t3-oss/[email protected]':
+ resolution: {integrity: sha512-NNFfdlJ+HmPHkLi2HKy7nwuat9SIYOxei9K10lO2YlcSObDILY7mHZNSHsieIM3A0/5OOzw/P/b+yLvPdaG52g==}
peerDependencies:
arktype: ^2.1.0
typescript: '>=5.0.0'
valibot: ^1.0.0-beta.7 || ^1.0.0
- zod: ^3.24.0 || ^4.0.0-beta.0
+ zod: ^3.24.0 || ^4.0.0
peerDependenciesMeta:
arktype:
optional: true
@@ -4585,13 +4582,13 @@ packages:
zod:
optional: true
- '@t3-oss/[email protected]':
- resolution: {integrity: sha512-QmTLnsdQJ8BiQad2W2nvV6oUpH4oMZMqnFEjhVpzU0h3sI9hn8zb8crjWJ1Amq453mGZs6A4v4ihIeBFDOrLeQ==}
+ '@t3-oss/[email protected]':
+ resolution: {integrity: sha512-JfSA2WXOnvcc/uMdp31paMsfbYhhdvLLRxlwvrnlPE9bwM/n0Z+Qb9xRv48nPpvfMhOrkrTYw1I5Yc06WIKBJQ==}
peerDependencies:
arktype: ^2.1.0
typescript: '>=5.0.0'
valibot: ^1.0.0-beta.7 || ^1.0.0
- zod: ^3.24.0 || ^4.0.0-beta.0
+ zod: ^3.24.0 || ^4.0.0
peerDependenciesMeta:
arktype:
optional: true
@@ -8105,12 +8102,6 @@ packages:
peerDependencies:
react: '>=16'
- resolution: {integrity: sha512-JgKVnog9mNbjbjH9csVpMnz2tB2cT5sLF+7O47i6Ze/s/GoiKdV7dHhJHk1gwXpo6h5qPj5PTzryldtSjvrHuQ==}
- peerDependencies:
- next: ^14
- react: ^18
-
resolution: {integrity: sha512-clQRxsvf4nZktCYkP1seeNH5rOZjsx6VYSAlpphvXvW+INIBvGySEStKutwtAPFV0/uZFJmNPt77ankoepUYXQ==}
engines: {node: '>=18.17'}
@@ -15011,15 +15002,15 @@ snapshots:
dependencies:
defer-to-connect: 2.0.1
optionalDependencies:
arktype: 2.1.29
typescript: 5.8.3
zod: 4.2.1
dependencies:
optionalDependencies:
arktype: 2.1.29
typescript: 5.8.3
@@ -15480,7 +15471,7 @@ snapshots:
dependencies:
crypto-js: 4.2.0
optionalDependencies:
react: 19.2.1
@@ -19167,18 +19158,13 @@ snapshots:
- acorn
- supports-color
- dependencies:
- react: 19.2.1
-
dependencies:
react: 19.2.1
react-dom: 19.2.1([email protected])
dependencies:
react: 19.2.1