African Americans fought on both the British and Patriot sides. In 1775, Lord Dunsmore issued a proclamation offering freedom from slavery to any and all African Americans who fled to British lines. Many slaves took up this offer. For some, it was an opportunity to gain a better life and they relocated to Nova Scotia or other parts of the British Empire after the war. However, for others it continued to be a life of hard manual labor and high rates of disease and starvation.
While some New England states allowed African Americans to enlist in the Continental Army and militias, most other states prohibited their military service. From time to time, as manpower shortages occurred, this policy was relaxed somewhat.
Frey, Sylvia R. Water from the Rock: Black Resistance in a Revolutionary Age. Princeton, N.J: Princeton University Press, 1991.
Gilbert, Alan. Black Patriots and Loyalists: Fighting for Emancipation in the War for Independence. Chicago; London: The University of Chicago Press, 2012.
Horne, Gerald, and NYU Press. The Counter-Revolution of 1776: Slave Resistance and the Origins of the United States of America, 2016.
Quarles, Benjamin. The Negro in the American Revolution. Chapel Hill, NC: The University of North Carolina Press, 1961.
Don’t be put off by the title. This classic book is well worth reading.
Schama, Simon. Rough Crossings: The Slaves, the British, and the American Revolution. New York: Perennial, 2007.
Van Buskirk, Judith L. Standing in Their Own Light: African American Patriots in the American Revolution. Campaigns and Commanders, volume 59. Norman: University of Oklahoma Press, 2017.
There are several emerging databases of slave names and runaway advertisements. J. L. Bell in his blog provides an excellent summary.