A common question to ask when you're planning a trip to Gdańsk is "Should I stay in Gdansk or Sopot?". One of the first things you learn, unless you're already aware, when you start planning a trip to Northeastern Poland is that "Gdańsk" is more than just Gdańsk. In Poland, the area goes by the name Trójmiasto (Tricity) with Gdańsk, Sopot, and Gdynia as anchors.
I can't say that much about staying in Gdynia, but generally, it is not what you're visiting the region to see. When it comes to Gdańsk and Sopot they are quite different types of cities. Gdańsk is much larger and a city with lots of history, it was known as Danzig for much of its existence. Sopot is smaller and more similar to the tourist towns in Southern Europe with a large beach, and the main shopping street surrounded by apartment hotels.
It is very easy (and cheap) to travel between the cities in this region. So it's not a question of choosing one place to stay and not being able to visit the other. I stayed in Sopot but spent quite a lot of time in Gdańsk. My visit was a visit with the family in the middle of the summer, and with smaller kids in the group. The combination of a week-long visit, with kids, and in the summer is when it's best to look for accommodation in Sopot.
If you instead travel with friends, or just visit for 2-3 days, then it's usually better to stay in Gdańsk as there's more to do and see there. For solo travel, it's unquestionably better to stay in Gdańsk. If I went to the region alone I would probably not even visit Sopot as it is very family oriented.
The travel time by train between Gdańsk and Sopot is only 14 minutes on a train with the slowest speed I have ever experienced on the tracks. 14 minutes is still not much so you can easily travel between the two. If you would like to continue to Gdynia it's an additional 9 minutes from Sopot.
Driving is not recommended in the two city centers and it's not a necessity to rent one. If you do arrive with a car, for example as part of a road trip, I would say that it's better to stay in Sopot as it's easier to find parking. Few sights would require a car. The Westerplatte Peninsula with the ruins of a Polish Military Transit Depot and the site of the first battle of the Second World War is the one sight I can think of where access to a car is beneficial. However, Uber is so cheap in Poland that you can easily just ride with them. The price to travel between Gdańsk and Sopot is roughly $12.
My Recommendation
If I went back I would stay in Gdańsk. There's more to do there. It's actually also cheaper since Sopot is one of the most expensive towns in all of Poland. But if I go back I would most likely not be traveling with my family but rather alone or with friends on a short weekend. Sopot is the better option if you travel with kids.