Simple ESP32 driver for solenoid valve rated 24V/2A?
It's easy enough with a logic-level MOSFET, but unfortunately most good logic-level MOSFETs are in hobbyist-unfriendly SMT packages.
If an SO-8 is okay (easy to solder on breakout boards) then something like the IRF7470 will do the job.



simulate this circuit &ndash; Schematic created using CircuitLab
It has an Rds(on) of less than 30m\$\Omega\$ with only 2.8V drive, so power dissipation will be less than 120mW (very low, barely warm).