I'm a nursing student. How do I deal with loss of a patient?

Experience. Time, patient & accepting that no one is immortal always more difficult to deal with a young patients death than an older.
Loss. Your school may have some resources for grief counseling. Often social workers or psychologists work with small groups of students to help them deal with losses of patients. If not, try the student health counseling services usually available through the student health office.
Takes time. I deal with loss frequently in my field. It never gets easy, but you can develop the skills to cope with the losses. First, it is okay to feel sad and even to cry in front of the patient's family. Of course , a modicum of control is necessary, as you are a professional. Knowing you did your best to care for the person and then enjoying other healthy escapes will help you cope more effectively.