The best way to prevent melasma is to limit skin exposure to the sun. If you go out in the sun, take these preventive measures:
Wear a hat with a brim to shade and protect your face.
Apply sun block (such as zinc oxide or titanium dioxide) to vulnerable areas.
Use sunscreen that protects against both ultraviolet A and ultraviolet B radiation. The sunscreen should have a sun protection factor (SPF) of at least 30.