I use what fits each campaign depending on how it is going to be run.
Published campaign? I hand out XP because some of my players like tracking it and seeing how close the next level up is getting, but if the party falls behind the level the author built challenges for (which usually happens because authors include optional parts that don't hook my players' interest because they are already hooked on the "main goal" and see them as unnecessary distractions, or because the author assumed a singular solution to a problem that clearly had more than one possible solution and my players came up with a solution that should work but isn't covered in the book) I bump them up to where they are intended to be.
Something I've personally done the planning for? I don't plan in great detail, basically just an outline that I fill in at the table with improvisation, but I'll include level increases at certain points in my plan specifically so that I don't ever come to a moment where I want to move on to the section that features a particular set of monsters, but have to "fill in" some more XP-gains beforehand in order to get the party to a level where the upcoming challenges are fair.
The bulk of my campaigns? I don't plan anything, and I don't use anything published. I give the players a few premises to choose from, they pick one that sounds interesting, we work together to build characters and begin the campaign, then my players are the ones in control because all I am doing is filling in the world as relevant to how they decide to interact with it. So I hand out XP based on accomplishment of goals the players set, because there is no "next part of the story" to require them being a particular level so whether they level up now or later isn't a big deal, since they are primarily in charge of the leveling pace (by setting goals they pick how much XP is on the table, and by working at their own pace to reach those goals, they pick how quickly the XP on the table is earned).
For no reason other than that I prefer being able to go from "What she we do tonight?" to the first events in-play during a D&D campaign in an hour or less, I prefer doling out XP for each thing accomplished - the only other option when improvising a campaign like I do is for me to just decide from time to time "it's time to level up," and I don't like the way that feels.