The decision between using a router vs using a hub really depends on what your end goal is. Are you trying to connect all devices on your network together to make sure they all have the same info? Then a hub is likely your best bet. Every device on your network will have a Network Interface Card (NIC) which allows it to access your network. This NIC is where your Media Access Control (MAC) address lives. We will come back to your MAC address in a little bit.
You can send and receive information with a hub but there is not a lot of intelligence built in. Hubs use CSMA-CD which stands for Carrier Sense Multiple Access-Collision Detection. In simple terms this means that anything connected to the hub can see the network (CS) and that all devices connected have equal access (MA) meaning they can send anything at any time, even if it’s at the same time as another device. Since these hubs are not very smart, things you send (packets) can sometimes collide with other packets sent from another device which is where the Collision Detection comes in. When a packet collision is detected, the NICs of each device involved in the collision will generate a random number to determine which sends first. Now, these things can and do happen very quickly. However, if you have many devices on your hub network, the amount of time needed to get these collisions sorted out goes up exponentially. This is why hubs have mostly faded out of the limelight in favor of switches.
If you want to intelligently send packets over your network to a specific device, or have one thing talk to something else like a Network Attached Store while someone else sends a file to a printer, then a switch is what you will want. Switches will build a MAC address table when connected to your network and will use this table to send your data to the proper recipient without your devices tripping over one another. Depending on your application, you might need either a managed or unmanaged switch. The difference here is that an unmanaged switch can be a sort of “set it and forget it” where a managed switch allows you to log in and set permissions and manipulate many other settings, but I believe that is a bit beyond the scope of the original question. Switches are dominating the networking market and hubs have, more or less, gone the way of the dodo. Hubs can still be purchased but remember, there is no intelligence to what is sent where.
All of what I’ve shared here is on an extremely basic level but I hope that it is enough to help you decide what is best for your case. For some more in-depth reading, check out this link: Hubs vs Switches