environment-badge
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

preview

environment-badge - simple zero-dependency environment indicators

npm version npm bundle size



It's easy to get disoriented when your application runs in multiple environments. This package checks the domain & adds a simple indicator to let you know when you're not on production. It looks for the following environments out of the box:

  • Local development, at localhost or .test domains.
  • Development environments, at dev. or *-dev. subdomains.
  • QA environments, at qa. or *-qa. subdomains.
  • Preview environments, at preview. or *-preview. subdomains.

Usage

If you're building your application with Webpack, Create React App, or a similar tool, simply import this module:

require('environment-badge')();

For applications without a front-end build system, you can embed this script from unpkg:

<script
  type="text/javascript"
  src="https://unpkg.com/environment-badge@^1.0.0/dist/bundle.js"
></script> 

Advanced Usage

You can customize what environments are checked for by providing an array. For example:

require('environment-badge')([
  {
    displayName: 'local',
    host: /(^localhost$|\.test$)/,
  },
  {
    displayName: 'staging',
    host: /^([a-z0-9-]*-)?staging\./,
    backgroundColor: '#000000',
    foregroundColor: '#fcd116',
  },
]);

License

© DoSomething.org. environment-badge is free software, and may be redistributed under the terms specified in the LICENSE file. The name and logo for DoSomething.org are trademarks of Do Something, Inc and may not be used without permission.

Readme

Keywords

none

Package Sidebar

Install

npm i environment-badge

Weekly Downloads

121

Version

1.3.1

License

MIT

Unpacked Size

8.59 kB

Total Files

6

Last publish

Collaborators

  • dosomething-admin
  • dfurnes
  • weerd
  • mendelb