For something super simple, use a couple ideal diodes to auto switch between highest voltage.
For example LM66200 is a package with two ideal diodes, and automatically outputs highest voltage :
https://www.digikey.com/en/products/detail/texas-instruments/LM66200DRLR/15856663?s=N4IgTCBcDaIDYFsBsSwAY0gLoF8gUp until a few days ago, it was in stock in thousands of units, someone probably bought a few reels.
LM66100 is the single diode version, but you can combine two to reproduce the LM66200 functionality :
https://www.digikey.com/short/52pwqr98MAX40200 is another example of ideal diode that you could use :
https://www.digikey.com/en/products/detail/analog-devices-inc-maxim-integrated/MAX40200AUK-T/7392218So you could use an ideal diode or a regular schottky diode on the 5v input , and an ideal diode after the battery ... their cathodes join together to feed your switching regulator or linear regulator.
When you plug the charge cable, the 5v - voltage drop on diode will be higher than 4.2v (minus ideal diode drop) so it will "win" and your regulator will be powered by the dc input.
There's also more expensive chargers that have built in power output, but they're more expensive than tp4056 chips.
For example MCP73871 has an output voltage pin, when the DC input is present an ideal diode inside connects the input to output, when DC is gone it connects the battery to output.
MPS makes similar charger chips, but a lot of them put on the output the voltage used to charge the battery, not the 5v on input. So for example depending on how charged the battery is, you'll get a minimum of 3.6v on the output pin and up to around 4.4v when the battery is fully charged, and when the input is disconnected the chip connects the battery to the output pin.
For example see MP2667 :
https://www.digikey.com/en/products/detail/monolithic-power-systems-inc/MP2667GG-0000-P/11610986The i2c on the chip is optional, but you can use it to program certain parameters of the chip once (they're saved in internal memory) and then it will run on its own, without i2c connection.
There's also MP2637 :
https://www.digikey.com/en/products/detail/monolithic-power-systems-inc/MP2637GR-Z/5292187This one has a built in boost regulator and will boost the battery voltage to 5v before it puts it on output pin - if your microcontroller doesn't need 5v it won't be a good choice from an efficiency point of video (no sense boosting to 5v and then bring it back to a low voltage like 1.8v/2.5v/3.3v etc