I did this, actually! In terms of disclosure, @eric allam is absolutely correct, above; you should let your users know that's going on, at a minimum, and ideally have some sort of "Start mining" button they can click to have an explicit opt-in type procedure. That said, it's wildly unlikely to generate a profit unless you have a huge base of users and are providing some sort of content (a game, streaming music, etc.) that they would want to stick around for.
I started (Let's) All Mine as a sort of experiment (to raise money for grad school) inspired by The Million Dollar Homepage, thinking that a site that is only about mining would be a curious thing users might want to be engaged with, similar to how that site was only a site of ads. I also thought it was a low bar for users to engage with, considering they can run it in the background on their browser while they're doing other stuff. The reality, though, is that I'm asking users to give up some fraction of their CPU, which, even though most users aren't using nearly all of it, is an ask. Also, it is very hard to get users to stay on a particular web page; given short attention spans and the habit of closing pages when we're done, it takes a special kind of user to stick around and mine for a while. And that's really what it takes: Coinhive's own site says with 10-20 "active users" (which I interpret to mean "users who are consistently mining 24 hours/day"), you can expect $30-40 per month. Maybe that covers your hosting and domain costs, maybe it doesn't, but you're not walking away with a whole lot. Finally, there are dedicated mining pools that reward users with some amount of currency depending on their contributions; what I'm asking for is a donation of time + resources, so it's not as palatable.
In any case, for my project in particular, it was exciting to make something in a weekend that was functional and get it out there. I've had a bunch of people stop by and mine for a minute or two, and the rare few miners that stay for a while, but I chalk it up to a learning experience. You have to get the incentives right to get users to come, and stay.