Hej, pronounced like English 'hey', is the Swedish word for 'hello' or 'hi', an alternative for hallå (hello) or goddag (good day). The first thing you need to know is that hej is the most common and safest of the three to use as a non-native speaker.
But it's a surprisingly young word, at least in its current form.
The word hej has existed in the Swedish language for centuries, but previously it was an interjection, appearing for emphasis in old poems and songs, while hallå and goddag were used for greetings. Things started to change in the 19th century when the Geatish Society, a group of Swedish writers, decided to adopt hej as their greeting because they liked its Old Norse feel, and it later became popular among students at Swedish universities.
Hej didn't really take off until the 1930s, and for a while it was a specifically informal greeting. When Sweden had an informal and formal variant of 'you', hej was only used with people you called du (the 'informal' you). When the distinction between different forms of 'you' was scrapped in a language reform of the 1970s, hej became more and more common and is now the most usual greeting in Swedish.
So how to use it?
You use it on its own in passing, “Hej!”, or at the start of a conversation, “Hej, hur mår du?” (hello, how are you?). This also applies to emails, which are typically less formal than in English or many other languages — you'll sound much more natural saying “Hej Benny,” than “Kära Herr Andersson” (Dear Mr Andersson).
Ready to get even more informal?
In Swedish, it's fairly common to double up words for emphasis, for example tack tack (literally 'thanks thanks') and ja ja ja (yes yes yes). This also works with hej: saying hej hej is a slightly more enthusiastic greeting than a simple hej.
Another informal variant for emphasis is to use the preposition på, for example hej på dig (hello to you) or hej på er (hello to you, plural).
There's also the alternative hejsan, slightly more colloquial than hej. Again, this is a bit more enthusiastic — the suffix -san is common in a few Swedish exclamations, like hoppsan and jajamensan. All three of these variations tend to signal that you're in an upbeat mood and are talking to a friend.
And there's a different word altogether, tjena, used to say 'hi' to friends and family in informal settings. But if in doubt, always stick with a simple friendly hej.
The final thing to know about hej is that it's not exclusively used at the start of meetings. Hej då is the Swedish term for 'bye', and this is often shortened to simply hej.
So on that note, hej!
Vänta, jag måste säga hej till Johanna
Wait, I have to say hello to Johanna
Hej, hur är läget?
Hi, how's it going?