A good candidate is the 1913 (Published 1914) novel by H.G. Wells, The World Set Free .
Synopsis of the novel : 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)
scifi.stackexchange.com/users/12305/JohnP
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).
scifi.stackexchange.com/users/83999/Zeiss Ikon
"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.
scifi.stackexchange.com/users/44649/JRE
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.
scifi.stackexchange.com/users/103134/Carl Muller
The Stars, Like Dust was published in 1951, after atomic bombs had been seen in use.
It mostly takes place off earth, but opens there.
Also consider On the Beach , published a bit later (1957).
scifi.stackexchange.com/users/43798/Mark Wood
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.
scifi.stackexchange.com/users/103132/Will Barnwell
The first one I know of is A Canticle for Leibowitz, 1959.  Are there any earlier ones?
What was the first work set in a post nuclear war earth?
scifi.stackexchange.com
<history-of><post-apocalyptic>
scifi.stackexchange.com/questions/191764
scifi.stackexchange.com/users/77805/Yozarian22
One story which features a similar scenario to a post-nuclear war earth is HG Wells' "The World Set Free", published in 1914. Other potential candidates for the first book to feature this scenario include "Tomorrow Sometimes Comes" by Francis G. Rayer or "The Stars, Like Dust". A number of pre-1959 novels depict the Earth in a period after a nuclear war. The earliest may be The World Set Free (1914) by H.G. Wells, followed by Robert A. Heinlein's  Solution Unsatisfactory (1941), Tomorrow Sometimes Comes by Francis G. Rayer (1951), The Stars, Like Dust (1951) and On The Beach (1957).
The novel by H.G. Wells, The World Set Free (1914) describes attempts to rebuild after a war fought with nuclear weapons. Robert A. Heinlein's  Solution Unsatisfactory (1941) details the lead-in to nuclear war and its immediate aftermath. Tomorrow Sometimes Comes by Francis G. Rayer (1951) depicts a post nuclear holocaust world with a city ruled by a supercomputer. The Stars, Like Dust (1951) and On The Beach (1957) both depict post nuclear war Earth.