There are two people who can know whether the attack hits; the player or their character. In both cases the answer is the same.
In every game that I've played, players are not supposed to have knowledge of a creature's statistics, including to-hit modifiers. Additionally, they do not know all the different spell and feature effects that may change the attack roll before or after it is made. They may be able to deduce the these values through observation, however as they are not the DM, players cannot have absolute knowledge of the final value of a roll.
Therefore, a player can never know for certain whether the attack hits or misses until the DM declares whether or not the attack hit. So, as long as you use the feature before the hit is declared, you should be able to use this feature.
Despite the usage of the word "you", descriptions for spells are typically written as a description of what the character can do, not you as the player. I believe that the following is the most likely RAI interpretation:
The character has no knowledge of a creature's statistics, including a creature's to-hit modifier and their own AC. These exist purely as a way of indicating how good a creature is at hitting things, and as a measure of how difficult it is to hit a creature, respectively, from a gameplay perspective. They have no real in-game counterpart. Therefore, you seeing the value of the roll does not impart on your character any knowledge of whether the attack hits or misses them. As such you can use this feature after seeing the roll.
This question contains further elaboration on this topic.