Not getting a job you really want can be awful. You got the interview, but you didn’t quite nail the gig. Here is one piece of advice that may help you going forward when you don’t get the job.
Send a polite email to the interviewer to let them know you appreciated their time and are disappointed you didn’t land the job. Somewhere in the note ask them why. Was there anything you could have done differently? Do they have feedback on your resume or work samples? Was the other candidate chosen more qualified, and if so, what skills do you need to work on to get to that level?
Sending a kind email to thank them again (by saying again here I am alluding to the fact that you should thank them right after your initial interview too) and to let them know you really cared about the position is a good way to keep in touch. Another job opportunity may open in the future – whether it be at that same company or a different one with a similar position. And you want to be ready when that happens. By inserting the ask of why you may find out what skills you need to improve or what mistake to fix on your resume or cover letter.
It may work and it may not, you may get a generic reply or you may learn something extremely valuable. But when you don’t get the job, you won’t know why if you don’t ask.