The French invaded Tonkin during the Sino-French War in 1884-1885. It was then made into a French protectorate, along with the areas of Annam and Cochinchina, splitting Vietnam into three parts.
Hanoi became the capital of Tonkin and of French Indochina during French rule. Japan was given control of the area by the Vichy government in 1940. During this time, the Japanese took control of Vietnam briefly, allowing the French to remain as a puppet government. The French colonial rule ended however during the Japanese occupation of the area on March 9, 1945 when they imprisoned the Vichy French government. France was able to regain control in 1946.
After World War II, Northern Vietnam became home to the communist Viet Minh and Hanoi was reclaimed by the French. War broke out between the two areas in the First Indochina War. After a French defeat in 1954, Tonkin became a part of the communist state of Northern Vietnam.
"French Indochina in World War II." Wikipedia, Wikimedia Foundation, 8 Nov. 2016, https://en.wikipedia.org/wiki/French_Indochina_in_World_War_II. Accessed 7 Dec. 2016.
"Tonkin." Encyclopaedia Britannica, https://britannica.com/place/Tonkin. Accessed 7 Dec. 2016.
"Tonkin." Wikipedia, Wikimedia Foundation, 4 Dec. 2016, https://en.wikipedia.org/wiki/Tonkin. Accessed 7 Dec. 2016.