Interestingly, WD40 is a lubricant. I used to think that since it was a penetrating oil/water sealant it wasn't a lubricant, but that's not actually the case. They even have a "myth" that discusses the idea floating out there that WD40 isn't a lubricant.
It will provide some lubrication for a while, true. But it will also dissolve any of the proper lube that is there, so when the WD40 is chopped up by the chain you'll be left with nothing.
I like the Shimano PTFE dry lube[1] but there are plenty of other brands.