What is the main purpose of a router in computer network

The main purpose of a router in a computer network is to connect multiple devices or networks together and direct data traffic between them. It acts as a central hub that determines the most efficient path for data packets to travel from one network to another. Routers also provide functionalities like network address translation (NAT) to allow multiple devices to access the internet using a single public IP address, firewall protection to secure the network, and quality of service (QoS) to prioritize certain types of data traffic.