What is hey-listen?
The hey-listen npm package is a collection of utility functions designed to help developers with warning and invariant messages. It is often used to provide development-time checks and informative messages to developers, ensuring that they are using APIs or components correctly and are aware of any misuse or potential issues.
What are hey-listen's main functionalities?
warning
The 'warning' function is used to display warning messages in the console when a certain condition is not met. It is useful for alerting developers of potential issues during development.
import { warning } from 'hey-listen';
// Check if a condition is met and warn if not
warning(condition, 'This is a warning message if the condition is false.');
invariant
The 'invariant' function is used to enforce a condition. If the condition is not met, it throws an error. This is useful for ensuring that certain conditions are met before proceeding with code execution.
import { invariant } from 'hey-listen';
// Check if a condition is met and throw an error if not
invariant(condition, 'This error is thrown if the condition is false.');
Other packages similar to hey-listen
warning
The 'warning' npm package is similar to hey-listen's warning function. It allows developers to print warning messages to the console if a condition is not met. The usage is similar, but 'warning' is a standalone package focused solely on warnings.
invariant
The 'invariant' npm package provides functionality similar to hey-listen's invariant function. It is used to assert that a condition is met and throw an error if it is not. This package is also focused on a single purpose, providing a strict condition checking utility.
prop-types
While not a direct equivalent, 'prop-types' is often used in React applications to perform development-time checks and validations on the types of props passed to components, which is in line with the kind of development checks that hey-listen provides.
Hey, Listen!
Dev-ex warning functions with added childhood flashbacks

Hey, Listen! provides simple versions of the popular warning
and invariant
dev-experience functions.
The library checks against process.env.NODE_ENV
to minify away messages in production.
Install
npm
npm install hey-listen
Yarn
yarn add hey-listen
Usage
warning
import { warning } from 'hey-listen';
warning(false, 'Warning message');
invariant
import { invariant } from 'hey-listen';
invariant(false, 'Error message');