Before I get into it, just a quick heads up that I'll be abbreviating "character death and/or permanent injury" as "CD/PI".
Forgive my bluntness, but character death is completely unecessary. I'll elaborate.
There's this idea in many roleplaying circles - whether that be PBP, TTRPG, or LARP - that have this idea floating around that CD/PI is an inherently "mature", "gritty", or "dark" topic. So much so that certain spaces I have been in simply refuse to question the idea. There's an assumption that it's default, almost necessary to make a game mature. And, of course, maturity is seen as a default goal to strive towards. So CD/PI is just on by default.
And honestly, that assumption is flat out horseshit. CD/PI is a tool, nothing more. Now, I have been in spaces that deal with it tastefully. I don't wanna say that it's always wrong. It's not. It can be wonderful when done well. Buuuut, on the other hand, more often than not I see it used by GMs as a tool to stomp on players.
But I digress.
Basically what ends up happening is that people will attempt to include CD/PI without questioning whether it's beneficial or necessary, or even better off without. They will include a disclaimer in the OOC or a spiel before session 0, and assume they're fine to just kill characters off as they choose. Worse yet is when there's no disclaimer, but that's obvious.
The problem with the disclaimer is that there's often no room for discussion. The attitude of "the GM is god" takes the front seat as they get to dunk in random situations where characters could die on a whim, usually without any discussion. Characters are subjected to CD/PI in entirely meaningless ways, and players are left with fucked plans, a character who they don't want to play, or just a dead character. They had no input, and the GM will often excuse themself by just saying "yeah but it's part of the RP", as if that makes the player feel better.
To make it worse, other players often repeat things such as "it's an opportunity to grow", or "it was an interesting story moment". These are both definite benefits of CD/PI when done well, but not when it's forced upon a player by a god GM. Effectively, the players end up pressuring each other into just accepting shitty GM calls.
What I'm trying to get at here is that CD/PI is often used as an excuse for abuse. A god GM fucks over a player, the player feels upset, then the community dismisses those very real feelings because "muh immersion". This is most prominent in LARPs, but definitely extends into the PBP and TTRPG communities as well. GMs insisting on CD/PI has been the root of many RP horror stories, and ultimately always will be. It's this weird paradox wherein the believing "CD/PI is mature" makes people play immaturely so they can say "wow look at how mature this game is, we have CD/PI!"
Anyway, sorry for the essay. CD/PI can be awesome when done right, so to actually answer your question.
I think that regardless of the medium, CD/PI should be a discussion between any and all relevant parties. If a character could die, talk about it. Engage with each other. Talk about whether they're comfortable with it, be mindful of triggers they might have, and make it clear that it's not the only outcome. Ask about plans they might have and whether they're more interested in exploring those, or the potential consequences of CD/PI.
Some great tools to use before starting any RP is the "same page tool" and the "RPG consent checklist". Both can be found via google pretty easily. Talk to your players as a group to see if they're genuinely interested in exploring it as an option, and respect it if they're not.
Ultimately it just comes down to respecting players, and making sure that you're not godmodding as a GM. Roleplay is a community storytelling experience, so the players really ought to be just as important in storytelling as the GM.
TL;DR immersion is less important than other people's feelings, so just talk about CD/PI. Don't force people into it because people have trauma. You don't need CD/PI to be a good writer or GM.