Miranda was approached by Abrams during an intermission of Miranda's Broadway musical, Hamilton, wherein Miranda jokingly suggested he would write the cantina music for The Force Awakens, if needed. Coincidentally, longtime Star Wars composer John Williams had recently asked Abrams to find a composer for the music to be played during the film's scenes set at Maz Kanata's castle. Abrams would accept Miranda's suggestion, and Miranda was brought onto the project to compose the music for the film's sequence.
Miranda and Abrams would go on to perform the song live as part of #Ham4Ham, a free pre-show provided to hopeful audience members queueing for the Hamilton ticket lottery outside of the Richard Rodgers Theatre in New York, on May 4, 2016, as part of Star Wars Day. That day, the then-unreleased song was released as a single on digital and streaming music services.