Skip to content

🎖 Add a visual "badge" indicator to differentiate QA environments from production.

License

Notifications You must be signed in to change notification settings

DoSomething/environment-badge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

🎖 Add a visual "badge" indicator to differentiate QA environments from production.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •