Home pregnancy tests detect the presence of the hormone human chorionic gonadotropin (hCG), which your body starts to release into your urine shortly after conception. To get a bit technical, the sticks or cups which catch your pee contain antibodies coated with a chemical that bonds to hCG if it's present, delivering a positive result. If the molecules do not bond with any hCG, you get a negative result. However, because hCG levels are very low early in pregnancy and ramp up as your pregnancy progresses, it's possible to get a negative test result (but actually be pregnant) if you test too early.
Some of the latest digital tests (they look like a pen-shaped instrument instead of a traditional stick), rely on a method called "rapid assay delivery," which can give results in as little as three minutes and even tell you if the test wasn't used properly.
Your doctor can also do a blood test in the office (hCG is released into your bloodstream as well as into your urine) to find out if you're pregnant. These tests are way more sensitive than urine tests, so they can detect a pregnancy almost immediately after conception. (This is ideal for women who need to discontinue certain medications as soon as they learn they're pregnant, for example). In the past, doctors almost always used to confirm home test results with an in-office blood test, but because today's home pregnancy tests are much more sensitive and accurate than older versions, many offices no longer do this.