First time Dm, question about pacing.

Should I write out the whole story and what I want to happen before the campaign or during to like, better fit what the players want to do? I’m making my own world and story and stuff sooo idk.