Transition to formula or BF on meds?

My baby is 2 weeks and 2 days old. I'm considering transitioning to formula because I had anxiety pre-pregnancy and I think it'd be best to get back on anxiety meds. My first thought is to formula feed rather than continue breastfeeding after I restart them although I want him to have all the benefits of BF. However I have heard some medications are safe while breastfeeding? Any personal experiences or advice on this?