Period pain (dysmenorrhoea) is caused by the uterus contracting. Non-steroidal anti-inflammatory drugs such as ibuprofen and naproxen are commonly used because they target the chemicals (prostaglandins) that drive the cramping; paracetamol is an alternative if NSAIDs do not suit you. Always follow the package instructions and ask a pharmacist or doctor about the right option and timing for your situation, especially if you have stomach, kidney, asthma, or heart conditions or take other medicines.
Non-medication measures genuinely help too: a heat pad or warm bath, light exercise or stretching, staying hydrated, and rest. Some people find that starting pain relief at the first sign of cramps works better than waiting.
See a doctor if cramps are severe enough to stop you doing normal activities, are getting worse over time, do not respond to usual pain relief, or come with very heavy bleeding, pain during sex, or pain outside your period. These can point to conditions like endometriosis or fibroids that benefit from treatment.