I'm unsure whether getting hit and taking damage happen at the same or different times.
The armor of Agathys spell is an example of when this doesn't matter as it states:
If a creature hits you with a melee attack while you have these hit points, the creature takes 5 cold damage.
This effect does not require any sort of reaction, it simply happens simultaneously with the hit, no matter what.
However there are features where the answer does matter such as the Sun Soul Monk's Sun Shield which states:
If a creature hits you with a melee attack while this light shines, you can use your reaction to deal radiant damage to the creature.
This requires your reaction, and we know that reactions (typically) happen after their triggers as supported by this Q/A ("Do reactions interrupt their triggers or not?") so the Sun Shield effect definitely happens after you are hit (making it a distinct scenario from armor of Agathys).
But are getting hit and taking damage simultaneous events?
If yes, then the reaction would occur after the hit and thus after the damage.
If no, then the reaction would occur after the hit but before the damage.
When the reaction can occur is important.
Let the Monk have only 1 HP left and be hit by an attack from a creature.
If they are hit and take damage simultaneously, then they would fall unconscious and be unable to take the reaction.
If the hit happened before the damage they could take their reaction, dealing damage to the attacking creature, and then take the damage, falling unconscious as a result.
Below is a collection of what I could find that potentially helps to answer this question:
I have found this Q/A ("Does damage from Armor of Agathys take place before or after a character takes damage from an attack that hits?") where an answer states:
Since the determination of a hit is before the damage is dealt, the attacker would take the damage from Armor of Agathys before the damage of the attack is resolved.
And also this Q/A ("What happens if a creature is killed between its attack and damage rolls") where one answer states:
The order is this:
- The Goblins hits the Warlock with a successful attack
- The Warlock takes damage from the successful hit and the Goblin takes 10 cold damage-these are both a direct result of the successful hit on the Warlock.
- The Goblin becomes incapacitated / dies as determined by the DM.
And another answer states this:
If I go by a strict reading of the rules, this is what would happen:
- The Goblins hits the Warlock
- The Goblin takes 10 cold damage
- The Goblin becomes Incapacitated (and probably dies because it is just a mook)The (incapacitated) Goblin deals damage to the Warlock
The Monster Manual when describing the notation "hit:" states the following:
Hit. Any damage dealt or other effects that occur as a result of an attack hitting a target are described after the "Hit" notation.
there is a section in the DMG on "Rolling Attacks and Damage" which states:
Players are accustomed to rolling an attack roll first and then a damage roll. If players make attack rolls and damage rolls at the same time, the action moves a little faster around the table...
And then there is also a section of the rules on "Making an Attack" which states:
3. Resolve the attack. You make the attack roll. On a hit, you roll damage, unless the particular attack has rules that specify otherwise. Some attacks cause special effects in addition to or instead of damage.
I'm unsure whether these point towards damage and hits being simultaneous events or not.
Finally, the lead rules designer, Jeremy Crawford, has made a couple unofficial rulings (tweets) regarding attacks hitting and damage, in particular this one and this one
Q. Solar HITS w/ Slaying LB on a 101~HP target, Death con saving throw req. start with the HIT or after damage reduction?
A. Slaying Longbow sequence:
1. Hit
2. Deal damage (apply any resistance)
3. Make saving throw if the target has hit points ≤ 100Q. Just for clarification, this means you can declare a divine smite/sneak attack after an attack roll, but before a dmg roll?
A. (1) You make an attack roll.
(2) You hit or miss.
(3) You roll damage if you hit. "When you hit" happens at number 2.
Yet again, I'm unsure whether these Rules As Intended ideas show that the hit occurs mechanically before damage or if that's just how it goes in the real world.