What is the best way to know if you are having a miscarriage within the first weeks of pregnancy?

Ask an OBGYN doctor. There are several ways doctors can evaluate. Specialists in obgyn can evaluate whether a miscarriage is happening. Subspecialists in reproductive medicine, fertility/rei, and maternal-fetal medicine can comment on potential for future problems. One place to start to gather information on healthtap is reading a guide like this one on bleeding in pregnancy https://www.Healthtap.Com/health_guide/5.
Bleeding and cramps. In the first weeks of pregnancy it is difficult to know if a miscarriage has occurred as blood and urine tests are usually not reliable. During this time, ultrasound is not very useful either. If a woman miscarries during the initial weeks of pregnancy, she may notice bleeding and/or cramping that occurs. Otherwise it is difficult without pregnancy testing through blood, urine or ultrasound.