Innā lillāhi wa innā ilayhī rājiʿūn.
Verily, from Allah we came and to Him is our return.
كُلُّ نَفْسٍ ذَائِقَةُ الْمَوْتِ
Every soul shall taste death… 
Death is an undeniable fact. Time after time, we as human beings lose ourselves in this temporary world as if we are to live in it forever. Thus, Allah sends us signs and reminders with the biggest reminder being to see a loved one pass on from this world.
The loss of a loved one is undoubtedly a grieving matter and only those who have experienced it can know the true depth of the pain it causes when it strikes. But just like any matter for a Muslim, there is a way prescribed in Islam in how best to deal with the loss too – without transgressing the limits. A way that can best be summarized by these five pieces of advice.
1. Sabr (Patience)
Nobody can be given a blessing better and greater than patience. 
One of the toughest attribute to hold onto when a loved one passes away is to observe patience. Yet, it is this very trait that enables a Muslim to show his/hers contentment and reliance upon the decree of Allah at what has transformed before his/hers eyes, knowing too well that Allah never burdens a soul more than it can take and He will surely compensate the loss with something better.
This is why Prophet Muhammad (peace be upon him) informed us when is it that true patience is recorded with regards to being befallen with a calamity:
Verily, the patience is at the first stroke of a calamity. 
Note, observing patience doesn’t mean we can’t cry or feel down, especially for the first three days, for our own Prophet (peace be upon him) had tears in his eyes when his son Ibraheem passed away and he (peace be upon him) said: “We are very sad for your death, O Ibraheem.”  But what we cannot do is cry excessively, hit oneself, tear the clothes, question Allah’s decree and cause any self-harm. All of this is strictly forbidden and we lose out on a great reward which comes with being patient.
…but give glad tidings to As‑Saabiroon (the patient ones). Who, when afflicted with calamity, say: ‘Truly, to Allaah we belong and truly, to Him we shall return.’
They are those on whom are the Salawaat (i.e. who are blessed and will be forgiven) from their Lord, and (they are those who) receive His Mercy, and it is they who are the guided ones. 
2. Dua (Supplications)
Just as there is no denying about death, likewise Duas being the biggest weapon for a believer is unquestionable too. When our loved ones are alive, they make Duas for our well-being, now that they have moved on to the next world, they are reliant upon our Duas for them since they are in desperate need of them.
Many of us degrade the importance of making Duas by having a mindset of “All I can do is just make Dua now…”, when in fact Duas are our biggest assets and can even possibly change the decree of Allah to become another decree. But when people have this mentality, they tend to get involved in other acts, thinking the acts will benefit the dead, when in fact they don’t. Reading Qur’an upon the dead, having gatherings or thinking Duas are more accepted whilst at the grave are all forms of innovations in the religion and have no authentic basis. The Qur’an was revealed as a form of guidance and healing for the alive. Gatherings after the death on a particular day was never a practice of the righteous early Muslims, nor did they ever went to the graves with the desire of making Duas for the dead thinking they will be more accepted.
Stick to the Sunnah and know if we are doing it rightly then the ‘little’ we do can actually be ‘big’ in the sight of Allah. Make Duas for the loved ones forgiveness, especially the children for their parents for Prophet Muhammad (peace be upon him) said:
“A man’s status will be raised in Paradise and he will ask, ‘How did I get here?’ He will be told, ‘By your son’s du’aa’s (prayers) for forgiveness for you.” 
There are a number of authentic Duas one can make for the deceased. Here is one of them.
للهُـمِّ اغْفِـرْ لِحَيِّـنا وَمَيِّتِـنا وَشـاهِدِنا ، وَغائِبِـنا ، وَصَغيـرِنا وَكَبيـرِنا ، وَذَكَـرِنا وَأُنْثـانا.
Allaahum-maghfir lihayyinaa, wa mayyitinaa, wa shaahidinaa, wa ghaa’ibinaa, wa sagheerinaa wa kabeerinaa, wa thakarinaa wa ‘unthaanaa..
O Allah forgive our living and our dead, those who are with us and those who are absent, our young and our old, our menfolk and our womenfolk… 
3. Sadaqa (Charity)
Alongside the deceased Muslim’s own charity that he/she gave whilst he/she was alive giving him/her continuous reward, another beneficial thing a Muslim ought to do for their deceased loved one is to give charity on their behalf. This is a proven Sunnah and again one we should not take lightly.
Ibn ‘Abbaas (may Allaah be pleased with him and his father) reported that the mother of Sa’d ibn ‘Ubaadah (may Allaah be pleased with him and his father) died when he was away from her. He said:
“O Messenger of Allaah, my mother has died and I am away from her. Will it benefit her anything if I give in charity on her behalf?” He said, “Yes.” He said, “Then I ask you to be my witness that I am giving my garden al-Mikhraaf (so called because it bore so many dates) in charity on her behalf.” 
Give towards projects which provide water, build a masjid, a school or simply with food and clothes. Charity doesn’t only mean what you can give with money on behalf of your deceased loved one, but also it could involve you doing Hajj/Umrah, as long as you have done yours already. You can also observe voluntary fasts on behalf of the deceased. Alongside all of this, try to remember pieces of advice the deceased may given to you and try to act upon them. This will enable them to get the continuous reward for the knowledge they spread whilst they were alive. Remember, by doing all of this you are benefiting your own book of deeds too.
4. Forgiveness and Aiding
In life, we may have a number of disagreements and they can lead to holding grudges with one another. Forgiving the deceased of any wrong they may have done to you is a huge gift one can give to them. By letting go of a grudge or even something they owed you, you are showing a trait of being merciful which leads to Allah being merciful to you.
…and let them pardon and overlook. Would you not like that Allah should forgive you? And Allah is Forgiving and Merciful. 
Besides forgiveness, a Muslim ought to help a deceased Muslim with respect to their any outstanding debt he/she may have left behind. The living Muslims should also aid in the funeral too for this is one of the rights of a Muslim upon another Muslim. Aid the close relatives of the deceased at their time of difficulty knowing they are in need of any help that can come their way.
Finally, take these precious moments of pondering over the reality of this life and that we all will be joining the dead soon. We are told to remember death often and even encouraged to visit graveyards for such thoughts and sights allow us to get back on track and re-evaluate our state with Allah. Don’t let Shaytaan keep you busy with worldly talks, rather remind yourself and others around you death is round the corner and we all ought to do more to become better servants of Allah. By us reconnecting with Allah after the person’s death, the deceased may well get the reward for your good deeds too.
This is why Prophet Muhammad (peace be upon him) used to recite the following which shows wisdom of remembering death often:
لسَّلامُ عَلَـيْكُمْ أَهْلَ الدِّيارِ مِنَ المؤْمِنيـنَ وَالْمُسْلِمينَ، وَإِنّا إِنْ شاءَ اللهُ بِكُـمْ لاحِقُـونَ، (وَ يَرْحَمُ اللَّهُ الْمُسْتَقْدِمِينَ مِنَّا وَالْمُسْتَأْخِرِينَ) نَسْـاَلُ اللهَ لَنَـا وَلَكُـمْ العَـافِيَةَ
Assalaamu ‘alaykum ‘ahlad-diyaari, minal-mu’mineena walmuslimeena, wa ‘innaa ‘in shaa’ Allaahu bikum laahiqoona [wa yarhamullaahul-mustaqdimeena minnaa walmusta’khireena] ‘as’alullaaha lanaa wa lakumul- ‘aafiyata.
Peace be upon you, people of this abode, from among the believers and those who are Muslims, and we, by the Will of Allah, shall be joining you. [May Allah have mercy on the first of us and the last of us] I ask Allah to grant us and you strength. 
 Qur’ān | 3:185
 Sahih Al-Bukhari | Book 24 Hadith 548
 Sahih Al-Bukhari | Book 23 Hadith 372
 Uddat as-Sabirin wa Dhakhirat ash-Shakirin, by Ibn Qayyim al-Jawziyyah
 Qur’ān | 2:155-157
 Ibn Maajah, no 3660; see also Saheeh al-Jaami’, 1617
 Ibn Majah 1/480, Ahmad 2/368. See also Al-Albani, Sahih Ibn Majah 1/251
 Sahih Al-Bukhari | Hadith 2756
 Qur’ān | 24:22
 Muslim 2/671, Ibn Majah 1/494, the portion in brackets is from Muslim 2/671.