Yep! You can use your HSA to pay for glasses and contacts prescribed to you by your optometrist. That includes prescription sunglasses, too.
You can also use the funds in your account to pay for other optometry services (for yourself or eligible dependents, i.e. children, siblings, parents, or a spouse/partner).
These services include vision tests, detecting eye abnormalities, and prescribing medications for certain eye diseases.