With so much talk about seeking shade and wearing SPF — even on cloudy days and in winter — it can be hard to believe that exposure to the sun, in small doses, can be beneficial.

Sunbathing, which is the act of sitting or lying in the sun, sometimes with the intent to tan, may have some health benefits if done properly.

There’s a major difference, to be sure, between going outside for 10 minutes without sunscreen and regularly spending time in a tanning bed.

The risks of too much sun exposure are well-documented. Spending time in the sun without SPF is one cause of melanoma, among other conditions.

However, high doses of vitamin D — when exposed to sunlight, our skin turns cholesterol to vitamin D — have been shown to help prevent certain common ailments and diseases.

Sun exposure helps the body make vitamin D naturally. This vitamin is essential but many people don’t get enough of it. Vitamin D deficiency is common and some estimates say that 1 billion people worldwide are deficient.

Vitamin D can be difficult to get from food alone. It exists in certain fish and egg yolks, but most of it is consumed through fortified products like milk. Supplements are also available. The benefits of sunlight and vitamin D include:

  • Reduced depression. Fewer symptoms of depression may be reported afters spending time in the sun. Sunlight triggers the brain to release the hormone serotonin, which can boost mood and promote feelings of calm. Even without depression, spending time in the sunshine will likely boost mood.
  • Better sleep. Sunbathing can help regulate your circadian rhythm, and your body will start to get reliably drowsy when the sun goes down.
  • Stronger bones. Vitamin D helps the body absorb calcium, which leads to stronger bones and may help to prevent osteoporosis and arthritis.
  • Boosted immune system. Vitamin D helps the body fight diseases, including heart disease, muscle sclerosis, the flu, and certain autoimmune diseases and cancer.
  • Lowered preterm labor risk. Vitamin D can protect against preterm labor and infections associated with birth.

Keep in mind: The American Academy of Dermatology advises against using sun exposure as the primary method of getting vitamin D.

Sunbathing isn’t without risks. Too much time in the sun can lead to sun rash, sometimes called heat rash, which is red and itchy.

Sun exposure can also lead to sunburn, which is painful, may cause blistering, and can affect all parts of the body, even the lips. Sunburns may lead to melanoma later in life.

Polymorphic light eruption (PMLE), also known as sun poisoning, can happen as a result of too much time in the sun. It presents as red itchy bumps on the chest, legs, and arms.

Some dermatologists believe that, as long as you don’t have complications with usual sun exposure, you can sunbathe without sunscreen up to 20 minutes each day. To reduce the risk of sunburn, it may be best to stick to 5 to 10 minutes.

This will vary based on how close to the equator you live, your skin’s usual response to the sun, and the air quality. Poor air quality can block some UV light. Some research suggests that it’s more damaging to get a lot of sun at once than to slowly be exposed to it over time.

Sunbathing while pregnant has the potential to lead to dehydration due to sweating in the heat. Sitting in the sun for prolonged periods may also raise your core temperature, which can raise the temperature of a fetus. Some studies show higher core temperatures can lead to longer pregnancies.

Vitamin D is extremely important during pregnancy. Research suggests that 4,000 IU of vitamin D daily had the greatest benefits. To avoid the risks above, talk with your doctor about how you can get the right amount of vitamin D if you’re pregnant.

There are ways to safely sunbathe.

  • Wear SPF 30 or more and apply it 15 minutes before going outside. Make sure you cover your body in at least a full ounce of sunscreen. That’s about as much as the size of a golf ball or a full shot glass.
  • Don’t forget to use SPF on the top of your head if it’s not protected by hair, as well as your hands, feet, and lips.
  • Avoid tanning beds. Aside from being dangerous, most tanning beds barely contain UVB light to stimulate vitamin D production.
  • Take breaks in the shade when you get hot.
  • Drink water if you’re spending prolonged periods of time in the sun.
  • Eat tomatoes, which contain large amount of lycopene, which research has found helps prevent skin redness from UV rays.

Sunbathing is one way for your body to reap the benefits of the sun, but it’s not the only way. If you don’t want to lie in the sun but still want the benefits, you can:

  • exercise outside
  • go for a 30-minute walk
  • open the windows while you drive
  • park farther from your work and walk
  • eat a meal outdoors
  • take a vitamin D supplement
  • invest in a UV lamp
  • eat foods rich in vitamin D

Research shows there can be benefits to sunbathing and spending time in the sun. Exposure to sunlight can boost mood, result in better sleep, and helps vitamin D production, which strengthens bones and may help fight certain diseases.

However, because of the risks associated with too much sun exposure, limit your exposure time and wear sunscreen SPF 30 or above. Unprotected sunbathing can result in sun rashes, sunburns, and a greater chance of developing melanoma.