It's always suggested to first contact your vet for any potentially dangerous injuries. If you noticed the injury at home, there are a few things you can do first.
Protect yourself from any biting and restrain your dog to examine the area. Your dog will be hesitant so handle them with extreme care.
If they will allow you to touch the area, you can begin to address bleeding if there is any. Apply light pressure to the area, or even dip the nail in some corn starch. If the bleeding doesn't stop after 10-15 minutes, it’s time to go to the vet. It's not recommended to apply a bandage at home, as this can be more painful and brew infection if kept moist for too long.
If there is a hanging portion of the nail, you can attempt to carefully remove it yourself. This should only be done the injury is not too severe and your dog is tolerating the pain well.
Always visit the vet if your dog’s nail breaks. The tips above are to provide immediate care in that moment, but will not provide adequate care for more serious injuries.