Be There: My philosophy and practice in almost all that I do is to not go into any situation "prepared". Usually it's a waste of time. If I'm not prepared just as I am, then it's too late anyway. So, what I do is I just plop myself into the middle of a situation and let things unfold naturally. The hardest part, in my experience, is just getting yourself in the door. The rest takes care of itself.
Be Yourself: Don't try to be someone you're not. Be yourself. Don't try to be the perfect consoler or comforter. Just be who you are, naturally and spontaneously. You are you for a reason, so be yourself there. Offer yourself, without words, as a companion through this time of loss.
Don't Stay Long: Unless they insist that you stay, don't stay very long. Express your condolences, and stay a little while. If there are others there, you can, if you need to, take your clue from how long others are staying. If you feel it is time for you to go, then go. Cultivate a gift for reading people by their body language, etc., and you'll get a sense of when you are no longer required or welcomed or when it is good to go. It's always true that too little of a good thing is better than too much.
Get Physical: I've noticed that almost consistently that those who are grieving appreciate touch. When you walk in the room, hold their hand or hug them if you are comfortable with that, and perhaps again when you are leaving. There is comfort in physical contact.
Listen: Just listen to what they have to say. Even if they tell the same stories over and over again, just listen quietly. Smile. Cry. Do whatever, but just listen. Often what they say gives clues as to how they are really doing and how they are going to deal with this. And listen to them even if what they have to say at that moment isn't too pleasant to listen to.
Grieve With Them: It is okay to grieve along with them. But make sure that you are grieving with them and not for yourself. I've been in situations where it is obvious that a visitor is more upset about the death than is appropriate for themselves and that their emotions are so intense because they can't handle the reality of death, or they're recalling their own grief from a death in their own lives, or they are afraid of a similar tragedy happening to them, or something else. I've seen times when the grieving family end up trying to comfort a visitor who's out of control. You are visiting them primarily to bring them comfort, not to seek it for yourself.
Don't Be Shocked: Grieving is associated with some very strong emotions that can be expressed in surprising ways. Denial, anger, depression, and other kinds of emotions can turn up at any given time. Let them happen. So for instance, if a grieving widow starts cursing her dead husband who died of lung-cancer and calling him a stupid-son-of-a-bitch for smoking himself to death, don't try to get her to forgive him and be a nice lady. She needs to go through her anger, not suppress it. Let them scream, swear, cry, become lethargic, whatever! Even if they rage and swear against God, let it be. Encourage them to express their feelings. Healing happens faster and healthier if all the emotions are emoted.
Comfort: Often those who are left have feelings of guilt... that they could've done more or done something to prevent this from happening, or that they aren't doing very well right now and that they wish they could be stronger for everybody else. Encourage them to just be themselves. Nobody's expecting anything from them. Encourage them by saying that they did their best and are doing their best now. Provide a comfortable and permissive environment for the person to grieve in their own unique way. You can't take away their pain, so don't even try.
Be Practical: One of the things that people forget to do or can't be bothered with is practical things like food or errands. One of the things our community does, like many others, is organizing meals for a week or so for the grieving family. It really does help. Even if you bring a plate of homemade cookies, it means a great deal and won't be forgotten. Also, offer to do an errand, or watch the children, or go to a movie if appropriate, or just call once in a while to check in.
Be Patient: Grieving can last for years. Don't expect them to be over it just after the funeral. Anniversaries and birthdays and holidays can conjure up memories and send the person into another period of grief. Be patient, understanding and unconditional in your love and support for those who grieve. We will all be there at some time or another and need comfort ourselves.