Vet at FirstVet answers:
If your cat has had hard stools and struggles, but succeeds to defecate, there are a few things you can do at home to help it. The most important thing to do is to ensure your cat is drinking enough water. Give it some tinned food or add water to its dry food. The food should be an easily digestible diet (such as the special diets sold at your vets). Make sure there are enough water bowls at home so your cat always has easy access to water.
You must seek emergency veterinary care if your cat seems to be in pain, vocalizes a lot while it defecates, seems a bit off or is vomiting. Your cat may in this case require intravenous fluids, pain relief, and potentially an anaesthetic to allow giving it an enema to rid it of its constipation. If your cat has recurring issues with constipation or hard faeces there could be an underlying problem. Cats with kidney disease become constipated because they have a hard time staying hydrated, resulting in dry and hard faeces.