Kanye West provided a little joy in a fan's final hours ... chatting with and rapping for her before she died.

We're told Kanye recently became aware of a young fan who was battling cancer. The fan's family tried hard to get in touch with him because the pre-teen was a huge fan, and last week -- when word reached Kanye, he jumped at the chance to connect.

Kanye FaceTimed the girl last week. They talked for awhile and the girl then asked Kanye to rap, "I Love Kanye" -- her favorite song. He was more than happy to oblige.