〜うちに
While… still lasts, before the chance passesmachine translation
FormationVerb dictionary form・ている form/い-adjective/な-adjective + な/noun + の + うちに
〜うちに expresses "do B while state A still lasts, because A will eventually change": 温かいうちに食べてください (please eat it while it's still hot). Behind the sentence there is always the idea "once A ends, it will no longer be possible, or you'll regret it."
The connections are very broad: verb in the dictionary form or ている (日本にいるうちに), い-adjective as is (若いうちに), な-adjective plus な (元気なうちに), noun plus の (夏休みのうちに). Compared with 〜あいだに (N4), which neutrally states a time frame with clear boundaries, うちに carries the nuance of "seize the chance before it slips away," and its time boundary is fuzzier.
The form 〜ているうちに has a second use: while doing A, a natural change happens before you know it: 音楽を聞いているうちに眠くなった (while listening to music, I got sleepy without realizing it). For a negative first clause, see the separate pattern 〜ないうちに.
Examples
温かいうちに、どうぞ召し上がってください。
Please help yourself while the food is still hot.
日本にいるうちに、富士山に登ってみたいです。
While I'm still in Japan, I'd like to try climbing Mount Fuji.
音楽を聞いているうちに、眠くなってしまった。
While listening to music, I got sleepy before I knew it.