Exclusive

The San Francisco 49ers didn't go home with the Lombardi trophy ... but they got a sick consolation prize -- an all-out rager with Lil Wayne and DaBaby ... and it was LIT!!!

TMZ Sports has learned ... the NFC champs hosted a bash outside the American Airlines Arena shortly after the devastating 31-20 loss in the Super Bowl ... but we're told everyone was in great spirits!

Play video content

Lil Wayne and DaBaby each performed some of their hits, the Niners players joined them on stage ... and Kyle Shanahan bro'd out with Tunechi!!

FYI -- if you didn't know, the Niners coach is a HUGE Wayne fan and even named his son, Carter, after the rap legend ... and we're told Shanahan made sure to point that out to Wayne during the party.

Get this -- both rappers got a fat check to perform at the party. Like, we're talking 6 figures.

But, the party wasn't just for the players ... we're told the York family (who own the team) had a front-row seat!