but Im wondering are starbases worth it for online matches?
Starbases basically give you total control of a gravity well. They give you a place to retreat and regroup when outmatched, and make it difficult (if not impossible) for the enemy to secure the planet while they're intact. In fact, each faction has an upgrade that does make it impossible for the enemy to bombard out the planet while the starbase is alive. Starbases also make it very difficult for the enemy to bypass a front-line world to attack less well-defended backwater worlds, and also punish them for retreating. They can also buy time for your fleet to respond to trouble.
They're also used when you're facing 2v1 scenarios. A starbase and a small defending force can hold a critical planet (like a homeworld) while your main force reclaims nearby planets. The enemy can try to follow you, but every time they pass through your homeworld, they take damage from the starbase while you don't. This lets you very easily run hit and run tactics against numerically superior foes. In a multiplayer match, one player who is keeping two opponents occupied takes a lot of pressure off the rest of your team.
Starbase tactics are actually quite advanced, since poor starbasing will just deplete your fleet of necessary units and smart opponents can work around them. So you need to place them very tactically and carefully and then use them strategically to pressure the opponent. The enemy must constantly be inconvenienced, blocked, and penalized by your starbase. If he's not, that starbase was a waste of money.
So can capital ships and normal frigate be enough?
Normally you do want to focus on fleet and capital ships. Mobile units can chase the enemy if they relocate, while a starbase contributes nothing to a battle if the enemy simply relocates. This is not to say that starbases are useless, but starbases are used to support and augment your fleet, not replace it. If you're spending so much on starbases that your fleet is crippled, a smart player will punish you for that.
What if I on expanded a few planets and the enemy attacks me.
This is why scouting is important. You need to know how close the nearest enemy is so your fleet is ready in time. To some extent, there's a bit of a gamble here since you usually have to pick your labs and capital ship before your initial scouting is done, but the map often will supply many clues (such as the position of allies) to help you make that decision.
The important thing is that you need to identify how close the nearest threat is and ensure you're ready to defend yourself when that threat arrives. One of the nice things about colonizing planets is that this puts a buffer between your core worlds and the enemy, so even if you do lose one at the start, this gives you some breathing time. In the early game, people can't afford siege frigates (and if they do their combat fleet is going to suffer) so bombarding is actually very time-consuming and gives you some time to counter.