This is a good question, and one that has been discussed many times in the forums.
The simplest answer, as @crevasse mentioned, is one of the Wi-Fi plugs that is designed for exactly this purpose. There are a couple of different brands. They work by regularly pinging a website (some brands let you choose what website you want to ping, others just make you use the manufacturer site). If the ping fails, The Wi-Fi plug then reboots itself. Simple, reliable, whether itโs overpriced or not is an individual evaluation.
See the following discussion thread: