Expressing "before" in Japanese is not as difficult as other similar temporal phrases, but it still come with its own set of challenges.
When used as a temporal word, 前 means "before". It can be used with verbs in the non-past tense or with other nouns. Because 前 is also noun, you need to use the particle の when it is after another noun phrase.
How long ago was that?
I bought traveler's checks before I went on my trip.
重言 Note: Some speakers use 旅行に行く, but this is traditionally incorrect. It is more correctly 旅行（を）する. This is because 旅行 literally means "going on a trip".
I got a passport before going abroad.
I wash my hands before I eat.
Before I got home, my host family mother had cooked.
This is a newspaper from 11 years ago.
I studied some Japanese before going to Japan.
He died three years ago.
10. 彼は3年前に死んでいた。 (今になってわかったこと)
He's been dead for three years.
It's been three years since he died.
Word Note: 亡くなる is more neutral than 死ぬ for when someone passes away.
前 also has the reading ぜん. When used as a suffix after Sino-Japanese words, it is a very formal and suitable for 書き言葉. Its usage is almost unheard of the spoken language, but it is part of the official reading of many phrases in the jargon of many fields.
12. 1日3回 食前に服用してください。
Please take (medicine) three times a day before eating.
Word Note: 服用する is more formal than 飲む and is used in settings in which medical terminology is most appropriate.
Reading Note: 一日 is not read as ついたち when 一日 is used to mean "a day".
Independent/autonomous inspection before use
Reading Note: Many people would think きじつぜんとうひょう meant 期日全投票. So, in the spoken language, this word should be read as きじつまえとうひょう.
Reading Note: 出生 is usually read as しゅっしょう. However, some organizations use the reading しゅっせい. For instance, in medical terminology 出生届 (birth registration) is read as しゅっせいとどけ despite the fact that most people say しゅっしょうとどけ. In the spoken language, 前 would be read as まえ as expected.
As a prefix, it is used to mean "ex-". However, it comes with the word 元‐, which also means "ex-" but implies that other "ex-..." have existed before. This, though, is not sufficient in distinguishing them all the time. Someone who has stepped back from his position would be 前〇〇. Before this person, anyone with the title would be 元〇〇. What if you had a boat and there were no person to carry the legacy after the vessel sunk? You would use 元船長 instead of 前船長.
The state of affairs of the current company president having murdered the ex-company president
has come to light.
My ex-girlfriend always gets to me no matter what.
Contraction Note: カノ is a contraction of 彼女 when used to mean "girlfriend".
Final Note: Aside from this, 前 read as ぜん exists in other time phrases such as 前日 (the other day).
Right before can be expressed with the word 直前. The word also has the literal direction meaning of "right in front of". When used in a temporal sense, it is frequently appended to nouns without the need of の. However, the use of の is most certainly appropriate in the spoken language.
I've also only managed to make it to a bus with an arrival time (to the airport) right before my flight back (to Tokyo).
Word Note: 帰京する ＝ 東京に帰る.
A person suddenly dashed out right in front of the/my car.
There was a smell of gasoline vaporizing right before the explosion.
漢字 Note: 臭い gives a nuance of stench whereas 匂い is any given smell. The word is also frequently spelled in ひらがな.