I think with anything in life, but especially the hard things, the best you can do is learn from it. Losing my dad meant learning a lot about things that are and aren't helpful when you're trying to support someone who is grieving. Along with basically everyone else, I've always worried about saying or doing the wrong thing in these situations. So I thought I'd share some advice based on my observations.
Say something. I can't think of a single person who said or wrote anything to me that felt like the wrong thing. Almost anything* you say is better than saying nothing. Consider your friend's preferences here. Personally, I hate to talk on the phone. Haaaaaaaaate. My friends went with email, text, or Facebook messages, which I vastly prefer. But maybe your person would find that impersonal and prefer a call. In my mom's neighborhood, it's common and acceptable to just stop by, something that might be alarming in other social circles, but that she appreciated.
*Ok, yes, there are some wrong things to say. Many of these things start with "Well, at least..." If those words spring to mind, immediately stop yourself. Anything that sets your friend up in competition in some sort of Pain Olympics is also wrong. If you want to share about your own loss from a desire to empathize, sure. If you want to prove that your loss was more painful, kindly shut it.
Share memories. I truly appreciated every comment on my Facebook post, but the one that stands out is from a college friend who commented that she fondly remembers my dad taking us out for pizza after football games. It was a simple thing from someone who really didn't know my dad that well, but it meant something to me that she remembered and mentioned it. It really was a comfort to me throughout to hear people's stories and memories about my dad. It's wonderful to hear that your loved one was loved by others as well. If you can think of something nice to say about the person your friend lost, say it. Even if you didn't know the person but can think of things your friend told you about him or her, refer to those.
Ask. One of the loveliest messages I got was from a friend in Okinawa who had never met my dad. She said "I'd love to hear more about him when you get back." This offer may seem simple, but it really is a gift. In addition to taking an interest in the lost loved one, you're also saying that it's ok for your friend to be sad with you. I think our impulse so often is to try to distract people from their pain. Letting them talk about it is so important. You may think that bringing up the loss will make your friend sad, but it's so much sadder to think that your lost loved one is forgotten or that your friends wish you'd just move on already.
If there's anything you can do - just do it. We all say it: "if there's anything I can do..." Here's the thing: if you can think of something to do, just do it without waiting to be asked. If you're very close to the grieving parties, you might do some cleaning, dishes or laundry, take the car and fill it with gas, grocery shop, mow the lawn, address thank you notes, or handle any other household/life tasks that might be a little bit overwhelming. If you're slightly outside that circle (but still local), likely your first thought will be food. We got a lot of lasagna and chocolate. Both of which are of course good things. You might consider bringing breakfast or snack food, to fill in some gaps. Cut veggies or fruit are good options since a lot of people go toward comfort (read: unhealthy) food. Something I wouldn't have thought of, but several people did, was buying paper goods. My mom is basically set for life on toilet paper and also got a lot of paper plates, napkins, and plastic utensils. If you can save your friend a trip to the store, especially a last minute "OMG we're completely out of toilet paper/diapers/whatever and have to go to the store right this minute" trip, that's helpful. Your person may or may not feel like getting out of the house, but offering to go for a walk is a low pressure way to help them make that happen. If you're not local, consider donating to charity, especially if the family has chosen one. Last I heard, more than $500 had been donated in my dad's name to Hope Hospice, which was a huge help to my family in my dad's last weeks. That's been a wonderful thing that came out of something so sad. Even if a charity hasn't been designated, you could choose one that seems fitting.
Don't post first. Ok, this should be obvious, but apparently it isn't to everyone: if you're not the closest person to the deceased, don't post about it on Facebook or elsewhere. One of my cousins announced my dad's death within hours, before we'd finished calling people. Fortunately, my dad wasn't on Facebook, so the cousin couldn't tag him, thus alerting everyone my dad would have been friends with before they heard it from one of us. I ended up posting before I otherwise would have, just because it was already out there.
Keep difficult dates in mind. A couple of friends, knowing that Mother's Day would be hard for me for infertility reasons, sent me supportive messages this year that I really appreciated. We're not there yet with the loss of my dad, but I know there will be some days that will be more difficult than others. For me, Father's Day comes to mind, as well as my dad's birthday and the anniversary of his death. If you can think of some of these days for your friend, make yourself a note to get in touch on that day and let your friend know you're thinking of her.
Maybe some of you have more ideas to add?