A compass is a very ancient device used to determine in which direction you are facing, which can be absolutely invaluable and navigation. Prior to the invention of the compass, sailors, travelers, even farmers moving about on their own property had to utilize the stars in order to determine in which direction they were facing. This works, but it’s not easy, and all one needs to do to realize that is to look into wayfaring, and nearly lost art Polynesians used in order to navigate the Pacific without the use of compasses.
A traditional compass utilizes a piece of magnetized metal which is attracted to the magnetic north pole of the planet. As the compass itself moves underneath the needle, it will overlap the direction you are actually facing due to this difference. The first compasses were simply magnetized pieces of metal floating in the water while suspended by cork, while watch style versions of it were quickly invented thereafter, and the bubble version used in airplanes, and on knives, etc. came along sometime in the 20th century.
Today, most compasses are electrical, using an FM tuner to determine the relative position of magnetic north, while others use accelerometers or magnetometers to achieve this. Pretty much any smartphone made after 2014 has the necessary hardware to run a very accurate compass application, but there’s something to be said about a traditional, unpowered compass to rely on you really need it.