As any conscientious modern parent should, father-of-one Adam Mansbach would regularly scour his local bookshop for help when faced with the challenges of looking after a toddler. But one particular area, he felt, was not getting sufficiently covered in a way he thought would chime authentically with your average worn-out mother or father: that of getting your child to sleep at a reasonable hour. And so the germ of an idea began to percolate.
"In absolutely every other way," says the American author of his now three-year-old daughter, Vivien, "she was wonderful and easygoing, a delightful child. There was no reflux, no colic, nothing awful like that. It was just, at night, she wouldn't switch off. It was driving us crazy."
The fact that he knew why she failed to settle made it no easier to bear: "She was learning so fast, at such an incredible rate, and so it was hard for her, I guess, to shut down. She would sit there in bed regurgitating everything she had learned that day, and she would go on and on and on. It was cute, really cute, but we were exhausted. We wanted to claim back the only free time we had in the day – the evening – to ourselves, but it was becoming increasingly impossible."
And so Mansbach vented his mounting frustration by writing poems that he believed accurately mirrored the emotions of any parent going through a similar situation. Eventually, he would collect them together in a book entitled Go the Fuck to Sleep, a series of sweetly lilting four-line rhymes that aped classic children's fare, but that, as its title rather gives away, came with a potent twist to render it anything but appropriate as bedtime tales for the under-fives.
"The windows are dark in the town, child / The whales are huddled down in the deep / I'll read one very last book if you swear / You'll go the fuck to sleep."
He found it cathartic, and, besides, it made him laugh. So he wrote more.
"The wind whispers through the grass, hon / The field mice, they make not a peep / It's been 38 minutes already / Jesus Christ, what the fuck? Go to sleep."
Shortly after, he posted a message on Facebook saying that people should be on the lookout for this phantom children's book of his.
"It was a joke, of course, because I certainly had no intention of actually writing it," he says. But those poems he put up online began to circulate, prompting some ecstatic reader feedback. "Suddenly everybody was demanding to know when the book was coming out," he recalls, shaking his head in disbelief. "That took me by surprise, to say the least."
All any writer craves is reader interest and so, thus encouraged, he sat down to write more verses, 14 in all. Then Mansbach contacted a friend, Ricardo Cortés, to provide some illustrations. An independent publishing company in New York, Akashic, acquired the US rights, cautiously presuming, but by no means yet convinced, that it might just strike a universal chord.
"If I didn't think seriously about publishing at first," says the imprint's founder, Johnny Temple, "then it was only because our speciality is urban literary fiction. But it was definitely an interesting idea, and being the father of two little kids, I immediately sent it to my wife and other parents to gauge their reaction."
The feedback he got, he says, was unanimous: "They were all vehement in encouraging me to publish it. My wife's email response was just two words: 'I'm weeping.'"
Meanwhile, the poems were going viral. "It was bizarre," says Mansbach. "They were generating so much online traffic, everyone forwarding the poems on to everyone else. Then, a couple of months ago, I gave a 10-minute reading of them in Philadelphia. The morning after, the book, which wasn't even out yet, went racing up Amazon's chart."
It is rare, Temple points out, to stumble on a book that has such a clear demographic. "You can't say that very often in publishing, trust me, but Adam's book quickly proved the exception. Parents with young kids is not only a huge potential audience, but also a continually regenerating one. In other words, we started to think this could be seriously commercial."
And so they promptly went into fast-forward mode in order to capitalise on the interest. Go the Fuck to Sleep was originally due to be published in October, but is now being rush-released on both sides of the Atlantic this month, advanced orders now somewhere in the region of 200,000. The UK rights were snapped up by Canongate.
"There are so many daily frustrating moments for parents that don't get covered within the Gina Ford Contented Little Baby Book model," Canongate's Francis Bickmore says, "which is why I think Adam's book is so clever, so resonant. It not only has such a strong sense of voice, but also strikes a note of solidarity for all parents. It's been incredible to watch just how massive this book has become, purely on word-of-mouth. It might just become the ultimate gift book."
The word-of-mouth buzz subsequently received a generous tailwind from the acclaimed American novelist Jonathan Lethem and musician David Byrne, among others. The breakfast TV circuit in the US began to request Mansbach as a guest. "I swear to you that there has been little calculation to all this," the author says. "It has come from a place of pure honesty, essentially one parent talking to another. I never expected it to explode into the zeitgeist." He laughs. "I always considered myself a literary novelist. Now, suddenly, I'm something else entirely."
It is early morning in Philadelphia, and Mansbach, 34, is on his way to Rutgers University, where for the last two years he has been a visiting lecturer. "It's my last week, actually, which is pretty good timing," he notes, "because what with all the activity over the book, I've been a little distracted during lessons." Had his tenure not been up, he suggests, "I'd have been sacked by now."
Mansbach has been a novelist for a decade, and comes from writing stock – his grandmother was a poet, his father a journalist. As a teenager, he weaned himself on the works of Kurt Vonnegut and James Baldwin – writers, he says, "that took on the ideas of culture and social identity". He has published four novels, none of which have appeared in the UK, but all critically acclaimed in his own country. His most successful was Angry Black White Boy, a satirical novel about race and cultural identity in the world of hip-hop. The book is now taught in more than 100 universities across America, and has been adapted as a play.
One thing he never envisaged was becoming was a writer of subversive children's rhymes. But then, he argues, he'd never had children before, and didn't realise what a rich source of inspiration they could be. "The first couple of years were pretty rough, though I should point out that it was my partner who dealt with it 75% of the time. In fact, she has only permitted me to speak about the book at all if I make it clear to everyone I talk to that it was mostly her. She says that if she hadn't been so tired herself, she'd have written it."
Like all parents in similar positions, the Mansbachs had their own ways of attempting to wind their daughter down before lights out: "We would establish what we thought was the appropriate atmosphere – low lighting, soft voices, a few gentle songs. But her delaying tactics just became more and more pronounced. She'd want a drink of water, she'd want to sit up and talk, to get up and run around …"
When Vivien did nod off, she was a teasingly light sleeper. "I'd forget which of the floorboards were the creaky ones, and so by the time I made it to the staircase, which groaned under my weight, she'd wake up, and we'd have to start the whole process over again."
That is why, when he finally made it downstairs, he felt inspired to write lines such as these: "The cubs and the lions are snoring / Wrapped in a big snuggly heap / How come you can do all this other great shit / But you can't lie the fuck down and sleep?"
But not everyone is laughing. As perhaps is inevitable for any book on parenting that proves a runaway success – in addition to its bestseller status, the film rights have been sold to Fox – Go the Fuck to Sleep has become the subject of mounting controversy, many taking umbrage at the fact that Mansbach has penned what looks like the sweetest of fairytales, only to then pepper it with rude words. Certain pockets of America, he cautiously admits, are up in arms about it, as is the Daily Mail's online comments section, one post describing him, and anybody who dares enjoy it, as sick.
"They are right now in the minority," he says. "Besides, I can't worry about it too much myself because a lot of my readers seem to be defending me against my critics," many of whom, he adds, are invariably not parents themselves. "I've had grandmothers springing to my defence! And if I've got grandmothers on my side, I think I'm going to be OK."
He confesses that he is bemused by just how comprehensively his life has been turned upside down these last few weeks, and how he is still trying to come to terms with this most unexpected success. He is also trying to keep pace with it, his publishers already planning a PG-rated version of the book, while many are already enquiring about a follow-up.
"I hope I can be classy enough not to cash in on this just because the opportunity is there," he worries, "but a lot of the suggestions are pretty funny. Somebody said that my next book should be called Eat Your Fucking Vegetables …"
Go the Fuck to Sleep is published by Canongate, £9.99. To order a copy for £7.99 with free UK p&p, go to theguardian.com/bookshop or call 0330 333 6846