Hadith.461 - Abu Ja'far, Imam Muhammad ibn Ali Al-Baqir (as), said:
"Walking behind the funeral procession is better than walking in front of it, but there is no harm if you walk in front."
Man Lā Yaḥḍuruh al-Faqīh #451Hadith.452 - Imam Muhammad ibn Ali Al-Baqir (as) said:
"Whoever walks with a funeral procession until the funeral prayer is offered and then...
Al-Kāfi #644“Abu Ja‘far (a.s.), has said, ‘(In a funeral procession) walk in front or behind (the coffin).”’