{"id":14384655,"url":"https://github.com/tusbar/next-runtime-dotenv","last_synced_at":"2025-04-06T08:13:13.474Z","repository":{"id":31275368,"uuid":"127421561","full_name":"tusbar/next-runtime-dotenv","owner":"tusbar","description":"Expose environment variables to the runtime config of Next.js","archived":false,"fork":false,"pushed_at":"2023-04-24T23:02:50.000Z","size":1949,"stargazers_count":160,"open_issues_count":5,"forks_count":4,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-30T07:11:12.216Z","etag":null,"topics":["configuration","dotenv","environment","nextjs","plugin","runtime"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tusbar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-03-30T11:40:08.000Z","updated_at":"2025-03-28T18:54:49.000Z","dependencies_parsed_at":"2024-01-14T20:17:23.574Z","dependency_job_id":"bc937920-30d8-41d4-8fd3-9aa3b9b0b2b1","html_url":"https://github.com/tusbar/next-runtime-dotenv","commit_stats":{"total_commits":260,"total_committers":6,"mean_commits":"43.333333333333336","dds":0.5923076923076923,"last_synced_commit":"d83383ea1798cd0a5481a5caad35512b51e8cc66"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fnext-runtime-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fnext-runtime-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fnext-runtime-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tusbar%2Fnext-runtime-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tusbar","download_url":"https://codeload.github.com/tusbar/next-runtime-dotenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247451665,"owners_count":20940944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","dotenv","environment","nextjs","plugin","runtime"],"created_at":"2024-08-28T18:01:33.274Z","updated_at":"2025-04-06T08:13:13.456Z","avatar_url":"https://github.com/tusbar.png","language":"JavaScript","readme":"# next-runtime-dotenv\n\n\u003e Expose environment variables to the runtime config of Next.js\n\n[![npm version](https://badgen.net/npm/v/next-runtime-dotenv)](https://www.npmjs.com/package/next-runtime-dotenv)\n[![codecov](https://badgen.net/codecov/c/github/tusbar/next-runtime-dotenv)](https://codecov.io/gh/tusbar/next-runtime-dotenv)\n[![XO code style](https://badgen.net/badge/code%20style/XO/cyan)](https://github.com/xojs/xo)\n\n## CI\n\n[![Tests](https://github.com/tusbar/next-runtime-dotenv/actions/workflows/tests.yml/badge.svg)](https://github.com/tusbar/next-runtime-dotenv/actions/workflows/tests.yml)\n[![Release](https://github.com/tusbar/next-runtime-dotenv/actions/workflows/release.yml/badge.svg)](https://github.com/tusbar/next-runtime-dotenv/actions/workflows/release.yml)\n\n## Getting started\n\n```bash\n$ yarn add next-runtime-dotenv\n```\n\nThis [Next.js](https://github.com/zeit/next.js) plugin uses [dotenv](https://github.com/motdotla/dotenv) to expose environment variables to the Next.js runtime configuration.\nIt requires `next@5.1.0`.\n\n## Usage\n\nThis module exposes a function that allows to configure a Next.js plugin.\n\nIn your `next.config.js`:\n\n```js\nconst nextRuntimeDotenv = require('next-runtime-dotenv')\n\nconst withConfig = nextRuntimeDotenv({\n  // path: '.env',\n  public: [\n    'MY_API_URL'\n  ],\n  server: [\n    'GITHUB_TOKEN'\n  ]\n})\n\nmodule.exports = withConfig({\n  // Your Next.js config.\n})\n```\n\nThen in your page, use the configuration values as such:\n\n```js\nimport getConfig from 'next/config'\n\nconst {\n  publicRuntimeConfig: {MY_API_URL},  // Available both client and server side\n  serverRuntimeConfig: {GITHUB_TOKEN} // Only available server side\n} = getConfig()\n\nfunction HomePage() {\n  // Will display the variable on the server’s console\n  // Will display undefined into the browser’s console\n  console.log(GITHUB_TOKEN)\n\n  return (\n    \u003cdiv\u003e\n      My API URL is {MY_API_URL}\n    \u003c/div\u003e\n  )\n}\n\nexport default HomePage\n```\n\n## Serverless deployment\n\nThis module is not compatible with serverless deployment as `publicRuntimeConfig` and `serverRuntimeConfig` from `next/config` will not be exposed.\nYou should use [build-time configuration](https://github.com/zeit/next.js#build-time-configuration).\n\n## Phases\n\nThis plugin leverages `next@5.1.0` and build phases. It exposes a plugin function in order to run the plugin only when running the server (`PHASE_DEVELOPMENT_SERVER` and `PHASE_PRODUCTION_SERVER`).\n\n## License\n\nMIT\n\n\n## Miscellaneous\n\n```\n    ╚⊙ ⊙╝\n  ╚═(███)═╝\n ╚═(███)═╝\n╚═(███)═╝\n ╚═(███)═╝\n  ╚═(███)═╝\n   ╚═(███)═╝\n```\n","funding_links":[],"categories":["📦 Legacy \u0026 Inactive Projects","JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusbar%2Fnext-runtime-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftusbar%2Fnext-runtime-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftusbar%2Fnext-runtime-dotenv/lists"}