Compression before recording vocals

I know how to use compression on an existing vocal track, however, how can I apply a compressor on the vocals BEFORE I even record them? This would be very useful in order to stop peaking as some songs have very quiet parts followed by very loud parts.

You can use a hardware compressor to compress the audio before it’s digitized.

They work at line level so it would require a “pro” setup with an XLR microphone, preamp, and an interface or soundcard with line inputs.

Or there is something called a channel strip (essentially the input channel from a mixer) that has all of those things built in.

A DAW can apply compression or other effects while recording but if you clip your analog-to-digital converter the damage done before any digital processing.

Thank you very much for the advice!!