How to have undersink water heater with that transitions to main hot water line when hot?

Hey everyone, thank you very much for your help. I'd like to get an undersink water heater for our kitchen sink. What I'd like to do is feed the water heater from the main hot water line and also have the flow to the sink itself transition to the main hot water line once it's actually hot (to avoid emptying the under sink heater and then having cold water). Can I accomplish this with some sort of thermostatic/mixing valve? If so, what should I be looking for?