How do I handle this?

I miscarried 2 months ago and now our good friends just told us that they are expecting. I don’t know how to be genuinely happen and not jealous. They weren’t even trying and they got pregnant. I don’t understand how that can even happen? It took us so much to get pregnant then we lost it. It’s just heartbreaking for us. How do I handle the heartbreak while still expressing happiness for them?