Most travelers in Spain pick one of four options. You can use your home plan and pay roaming fees. You can buy a local SIM card once you arrive. You can rent a pocket wifi device. Or you can install a travel eSIM before your flight.
Roaming is the easy one to rule out. If you are coming from outside Europe, your home carrier can charge a lot per day, and the bill is a nasty surprise. A local SIM is cheap but costs you time and a passport check. Pocket wifi means carrying a second gadget and keeping it charged. The eSIM skips all of that. It is just a digital plan that loads onto your phone.
Our cheapest Spain plan starts at $0.76. That is less than a coffee at a cafe on Las Ramblas, and you get a full gigabyte to start with.