There are three facets to this that are worth considering:
Prepare your players ahead of time
This largely comes down to four things. The first is setting up expectations during session zero. A core part of session zero for any campaign I run is what many of my recurring players refer to as my ‘Crit happens’ speech. I go over the general expectations for anything that could directly remove player agency from the game, including not only player death, but also things like various mind-affecting spells and abilities, covering both how likely they are to happen, and then covering how I handle them as GM. For player death specifically, it largely amounts to what I’ll be covering in the rest of this answer. Setting up expectations like this helps ensure the players know what they’re getting into and aren’t caught unawares by how I handle any such issues that arise.
The second is to have the characters establish general plans for the handling of these situations. I generally insist upon this as part of session zero, with the assumption being that the party would talk through such things in-character off screen shortly after coming together. I also have them have this discussion again whenever the party composition changes. The idea here is to make sure the players know what to expect from each other in a situation like this, and also to avoid cases where the party wastes resources on reviving someone who would rather just create a new character.
The third is to establish a way of warning players that they are doing something risky that their characters would know is likely to result in one of the situations covered in the aforementioned ‘Crit happens’ speech. My norm for this is that when a player does something that I estimate has a higher than 50% chance to result in such a situation based on information the character would have, I ask pointedly ‘Are you sure?’ before narrating the results of their declared action. In most cases, this results in them thinking for a few minutes before realizing they missed something that makes what they said an obviously risky choice, and then decide to do something much more sensible. Many more hardcore gamers are not enthusiastic about this when first told about it (and some will even actively ignore it), but most other players, especially newer ones, actively welcome this safety net, and even those who did not like the practice at first come to accept it when it ends up saving their character once or twice.
The fourth is something I’ve not personally seen many GMs do, but I would argue more should do. Put simply, I ask all of my players to have backup characters. As part of character creation, we go through creating a second character without equipment who will be held in reserve, and who gains levels in parallel with the main character. When their main character dies and they choose not to attempt revival, I give them the wealth total they have to work with for gear and have them kit out their backup character while the rest of the party finishes out the session, and then narrate their backup character joining in near the start of the next session. Having this fallback both helps ensure they can continue playing, and also helps to soften the blow of losing a character they enjoyed.
Handle things politely but efficiently in the moment
Put simply, keep things efficient when a player dies, but don’t skim over it either.
My ‘normal’ protocol for a character death is as follows: When the character actually dies (either they fail their last death save, or something else), I make sure I have everyone’s attention, then hand off to the player to narrate their own final moments (I have a handful of rules I hold them to, but it’s mostly just common sense stuff like being polite) before formally announcing the cause of death (I have a special voice that I use only for announcing character deaths) and finally recording the character in my ‘folio of fallen heroes’ (a running list I keep of every character who has ever died in any campaign I have run). Then, I usually call for a five minute break, and afterwards we jump right back into the action where it left off.
The idea here is to make the death feel impactful to the whole party, preserve player agency to the very end, and then make sure that the game can keep going so we don’t get too bogged down by it all. We’re there to have an adventure, not to play a funeral simulator (even though, most of my parties actually hold funerals in character after the fact for their fallen comrades).
Help the players continue on after the fact
Once the immediate danger is dealt with, I politely remind the party of the plan they agreed upon for such situations, including any relevant knowledge the characters might be expected to know for such contingencies (for example, if the player absolutely wants revived if possible, I inform the players of the required conditions for this and the nearest places they know of where they can get what they need to actually do it). I also gently nudge them in the required direction for any narrative cleanup needed (such as adding a player’s backup character to the party), and if I know the player is open to feedback I usually give them some (privately) about the events leading up to their character’s death.
The goal is to again not dwell too much on the character's death and keep the game moving while still supporting the player whose character died.