The chief activities include drinking beer by the bonfire; grilling meat; eating the traditional Midsummer cheese (with lots of caraway seeds) and singing and dancing in the open air.
In these events, going to sleep is taboo, as you are supposed to greet the sunrise in the morning.
Many Latvians will be leaving the capital for the countryside. While it certainly doesn't mean there's nothing to do in Rīga (there is always an extensive official program of events in the capital), it does mean roads are likely to be clogged, and the police will be conducting breathalyzer tests both before and after the actual party. So it's best to depart well in advance. Many cars will be decorated with leaves, wreaths and other folkloric symbols.
Those staying in Rīga will see the greatest parties held on the November 11 embankment and the Dzegužkalns hill across the River Daugava.
While it's understandable foreigners don't know traditional Latvian songs, singing along to the Midsummer songs' common refrain Līgo, Līgo! will help you get into the mood.
You can make your own traditional wreaths of oak leaves (for men, especially those named Jānis) and meadow flowers (for women, especially those named Līga), or head to Old Rīga where you can stock up on ready-made Jāņi wares at the annual Grass Market market near the Dome Cathedral.
Should you find yourself outside the capital and not really knowing what to do, there are always open-air parties held on outdoor stages in your nearest town, and hospitality is the order of the day so you are sure of a warm welcome.
It's a good idea to have mosquito repellent on hand if you intend to stay up all night, and if you've forgotten to stock up on cases of beer, these are sold pretty much everywhere, including at gas stations across Latvia.
It's possible someone may invite you for a walk into the fields of forest in search of the highly prized and rarely-seen "fern flower". This is a real honor, but don't be surprised if you discover something else entirely.
It's likely you'll be dared to jump over the bonfire. Maybe you'll have the nerve to follow Latvians in this adventure (best wait until the flames have died down a bit) -- but safety should be your main concern; the same applies to intoxicated swimming and driving under the influence, both of which are not wise.
You can find out more about Latvia's Midsummer traditions in this nice piece from the Latvian Institute.