Coming out can be a scary and vulnerable process for many people, and no one has to come out if they're not ready. When someone does come out to you by sharing their sexuality or gender identity, it is a sign that they trust and care about you.
To support them, you can thank them for telling you, and carefully listen without asking invasive questions. You can also ask if there is anything you can do to support them.
It is also important not to "out" somebody by sharing this information without permission, so ask if they would rather keep their identity private, or if they are happy for other people to know.