window-size
Reliable way to get the height and width of terminal/console, since it's not calculated or updated the same way on all platforms, environments and node.js versions.
terminal-size
Reliably get the terminal window size (columns & rows)
react-beforeunload
React component and hook which listens to the beforeunload window event.