The first one I know of is A Canticle for Leibowitz, 1959. Are there any earlier ones?
A good candidate is the 1913 (Published 1914) novel by H.G. Wells, The World Set Free.
The novel tells the prophetic story of man’s harnessing of the (at that time) newly-discovered power of the atom, and how this power nearly destroys civilization in a catastrophic war. In a sense, however, as we note below, it ended up being a self-fulfilling prophecy! The World Set Free is a remarkable example of how science and science fiction can interact with and build upon each other.
It goes on to detail the effects of the bombs, and how the world takes steps to prevent new outbreaks.
Wells's "atomic bombs" have no more force than ordinary high explosive and are rather primitive devices detonated by a "bomb-thrower" biting off "a little celluloid stud." They consist of "lumps of pure Carolinum" that induce "a blazing continual explosion" whose half-life is seventeen days, so that it is "never entirely exhausted," so that "to this day the battle-fields and bomb fields of that frantic time in human history are sprinkled with radiant matter, and so centres of inconvenient rays."
"Never before in the history of warfare had there been a continuing explosive; indeed, up to the middle of the twentieth century the only explosives known were combustibles whose explosiveness was due entirely to their instantaneousness; and these atomic bombs which science burst upon the world that night were strange even to the men who used them."
His solution (A common theme for him) was a unified world government:
Wells viewed war as the inevitable result of the Modern State; the introduction of atomic energy in a world divided resulted in the collapse of society. The only possibilities remaining were "either the relapse of mankind to agricultural barbarism from which it had emerged so painfully or the acceptance of achieved science as the basis of a new social order." Wells's theme of world government is presented as a solution to the threat of nuclear weapons.
"From the first they had to see the round globe as one problem; it was impossible any longer to deal with it piece by piece. They had to secure it universally from any fresh outbreak of atomic destruction, and they had to ensure a permanent and universal pacification."
(All emphases mine)
Robert A. Heinlein's Solution Unsatisfactory, published in 1941, details the lead-in to nuclear war and its immediate aftermath (using radioactive dust, not bombs).
The story resulted in a government investigation into John Campbell, the editor who accepted and published the story, as well as Heinlein himself, before those doing the investigating decided it was a coincidence, based on known science, and better to let stand (as opposed to quashing the story and possibly giving enemies a clue into weapons research that was only just beginning).
"By the Waters of Babylon" was published in 1937.
It doesn't explicitly mention a nuclear war, but the description of the war and that only knowledgeable people can safely handle artifacts from the destroyed cities certainly make it sound like there was a nuclear war. That, and that the cities themselves were "poisonous" for generations.
So, not explicitly a nuclear war but most likely describing the aftermath of one.
The story is science fiction doing what it does best.
At the time it was writen, nuclear bombs didn't exist. There was research into nuclear power going on, though.
The author took that idea of the current research, and mankind's tendency to make weapons out of everything, and combined them. Then asked (and answered) the question of where it could lead.
We by Yevgeny Zamyatin was published in 1921 and:
The action of We is set at some time after the Two Hundred Years' War, which has wiped out all but "0.2 of the earth's population". The war was over a rare substance only mentioned in the book through a biblical metaphor; the substance was called "bread" as the "Christians gladiated over it" — as in countries fighting conventional wars. The war only ended after the use of weapons of mass destruction, so that the One State is surrounded with a post-apocalyptic landscape.
However, perhaps this is my post-atomic brain equating WMDs to atomic weapons.
Tomorrow Sometimes Comes by Francis G. Rayer in 1951 predates 1959. In it, a nuclear bomber base commander (Rawson) is in a medically induced hibernation for an operation when the "atomic Holocaust" is unleashed. He wakes decades later to find his name is a swearword, and in the wasteland mindreading mutants rule. A new city is ruled by a (massive mechanical and valve driven) supercomputer.