Related Question on Metaculus:
Weapons in which the energy is provided by nuclear fission or fusion have only twice in history been detonated outside of a controlled test environment, in the Hiroshima and Nagasaki events in World War II.
Since then, the world has nearly gone to nuclear war as a result of international conflict (during the Cuban Missile Crisis) and by accident. There have also been a number of narrowly-averted accidental nuclear detonations. See this timeline for a sobering look at how close we have come.