J.R.R. Tolkien's first published book was "The Book of Lost Tales", which was a collection of his early writings about the mythology of Middle-earth. It was published posthumously in 1983.
However, if you're asking about the first book he wrote and completed, it was "The Fall of Gondolin", which he finished writing in 1917. It was a short story that formed part of the larger mythology of Middle-earth.