But if they choose to leave, do not offer them money to stay. Any employee who stays is not being very smart, the only interest the company has in paying you more is keeping you long enough to train your replacement.
If you were not worth X the day before you quit, how are you suddenly worth X the day you decide to quit?
I've seen people accept a counter-offer from a company, and very few of those lasted more than 6 months, or the amount of time it takes the company to make them no longer indispensable.
On the other hand, why would they have paid you X even if you were worth it, if they could get away with less?
This can easily happen when you are actually worth X, but the company thinks you are worth X-Y because they have a history of underpaying and perhaps were able to get away with it when the economy was down. If the market is willing to pay X for someone like you, you are worth X regardless of what your current employer thinks you are worth (as long as you act on it).