Skip to content

Commit

Permalink
feat: add t3 env for type-safe env variable (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahmiidris authored Jan 10, 2024
1 parent 0e62f7d commit 61abee0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
2 changes: 2 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './src/env.mjs';

import bundleAnalyzer from '@next/bundle-analyzer';

const withBundleAnalyzer = bundleAnalyzer({
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
},
"dependencies": {
"@next/bundle-analyzer": "^14.0.2",
"@t3-oss/env-nextjs": "^0.7.1",
"clsx": "^2.0.0",
"next": "^14.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwind-merge": "^1.14.0"
"tailwind-merge": "^1.14.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@commitlint/cli": "^17.8.1",
Expand Down
38 changes: 37 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/env.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { z } from 'zod';
import { createEnv } from '@t3-oss/env-nextjs';

const env = createEnv({
client: {
NEXT_PUBLIC_FE_URL: z.string().url(),
NEXT_PUBLIC_BE_URL: z.string().url(),
},
server: {},
runtimeEnv: {
NEXT_PUBLIC_FE_URL: process.env.NEXT_PUBLIC_FE_URL,
NEXT_PUBLIC_BE_URL: process.env.NEXT_PUBLIC_BE_URL,
},
});

export default env;

0 comments on commit 61abee0

Please sign in to comment.