Exit on double tap hardware Back

I’m looking to implement the now de-facto standard functionality of double tapping the hardware Back button to exit the app.
But I cannot find any guide how to do it on Ionic 5 (and preferably React, but not mandatory).
I looked here - Hardware Back Button - Ionic Documentation - but it didn’t really help.