A 1031 exchange can only be used for property held for business, trade or investment.
So a principal residence sale can’t be used in a 1031 exchange.
However, if the taxpayer converts the principal residence to one held for business, trade or investment, you can do a 1031 exchange.
So for example, suppose that you decide to change your principal residence into an investment property and start renting it out.
As long as you do it for a sufficient period of time; most tax advisors would say about a year; then you can defer the gain from the sale using a 1031 exchange if you buy another property to be held for business, trade or investment.