Someone promoted over you.
Try not to take things personally. There are many reasons why one person gets promoted over another which you can’t always understand unless you are the manager. For example, they may have some specific skills that are needed in the future such as speaking another language; they may have impressed a senior person who is pushing for the promotion; or they may have communicated their worth more effectively than you during 1:1 meetings with their boss.
Copy your rival. Be a detective and find out what they did. Are they the kind of person who always stays late? Do they do a lot of extra tasks or projects? Do they flatter the boss? As long as you are comfortable following their lead then you can be successful too. If you are not then it may be time to find a new job.
Promoted over someone.
Listen. Talk to your co-worker and listen to how they are feeling. You don’t have to agree with what they are saying or defend yourself but you can confirm their emotions. E.g. I can see how you would feel like that. But you also have to realize that the relationship changes. It’s hard to be best friend and boss. So you may talk about how you want to be friends but you will also have to do what is right for the team.