I echo the esim. I’ve used Truphone in the past. You can buy for 1 European country or all of Europe. Screenshot shows current prices for Spain.
Once you download the app, you simply switch to the esim in your phone’s settings when you want to use. Really easy to use.