[verb ない-form] + うちに
The grammar structure ないうちに is used to express doing something before a certain change or event occurs. It combines the negative form of a verb with うちに ("while"), literally meaning "while something has not yet happened." The emphasis is on taking action before it's too late – before the situation changes in an undesirable way.
The most common use is to urge or suggest that an action be taken before an unwanted change takes place.
The speaker implies that once the change occurs, it will be too late or inconvenient.
ないうちに can also describe something that happened while a state had not yet changed – often something unexpected or unintentional.
In these cases, the nuance is closer to "without (one's awareness)" or "before one knew it."
While まえに前に simply means "before" in a temporal sense, ないうちに adds a sense of urgency or a window of opportunity closing. It implies that there is a reason to act now – before the situation changes.
Compare: わすれる忘れるまえに前にめもメモしておこう – similar meaning, but ないうちに emphasizes the narrowing window more strongly.