Many things contribute to a good night’s sleep, from a good mattress to comfortable blankets and sheets. But when it comes to picking the perfect pillow, it turns out that “perfect” depends on how you tend to sleep.

Your pillow supports your neck and upper back as you sleep. According to Spine Health, they’re essential to maintaining the ideal support for your spine, neck, hips and shoulders. According to a 2011 study, a good pillow can even help you stay asleep longer. The key to finding the right pillow is knowing how you actually sleep.

With that in mind, here are the best pillows for each of the three main sleep types: back sleepers, side sleepers and stomach sleepers.

Back sleepers

Back sleepers need a lower-height pillow to avoid positioning the neck in uncomfortable positions. A too-tall pillow can cause migraines, body aches and spinal issues.

The Bluewave Ultra Slim Gel Memory Foam pillow, available on Amazon for $39.95, offers cervical neck alignment and promises deeper sleep. This pillow has cooling features and ventilation holes to increase air circulation. The pillow comes in the standard 2.75″ height, and its soft cover is washable.

The Harmony Pillow from Purple uses the same technology that has made the company’s mattresses best sellers. The inner core is hypoallergenic ventilated latex with breathable mesh material. The no-pressure support and cooling technology make the pillow feel “so special.” You can pick from three heights. Prices start at $143.

Stomach sleepers

Stomach sleepers put a lot of tension on their neck and lower back, according to the Mayo Clinic. If you’re a stomach sleeper, consider placing a pillow under your stomach and keeping your legs straight so your spine is aligned. To get the best sleep on your stomach, look for a pillow with a lower loft.

The Sertapedic Endless Comfort Bed Pillow has over 400 reviews and a 4.3-star rating. Its cotton cover provides lasting comfort, while the hypoallergenic fibers add a luxury quality. It’s available at Walmart for $14.88.

The Parachute Down Alternative Pillow has a 4-star rating with 577 reviews and is designed with three densities for your fill option. According to the website, it’s ”lighter and squishier” than other pillows making it a must-have for stomach sleepers. It’s available for $89.

Side sleepers

Side sleepers tend to deal with the most neck pain, and finding the right pillow can be difficult. A 2015 study suggested that a pillow height of about 10 centimeters is ideal for most side sleepers.

The Nectar Resident pillow earned a 4.5-star rating out of 380 reviews. This pillow has two kinds of foam that create optimum support and cushioning comfort. This pillow ensures the perfect height so your shoulders stay grounded without causing the pillow to fall flat. The Nectar Resident pillow is available for $50.

The Layla Kapok Pillow has over 3,000 reviews and a 4.5-star rating. The description says it’s a “luxurious pillow, plush and airy, soft and supportive at the same time.” What sets this pillow apart from the rest is it’s ability to become fully adjustable depending on your height preference. The Layla Kapok costs $109.