I need sleep!

My 7 year old wakes up every night and comes in my bed. He used to sleep in his own room all night no issue. The past year he has woken up every night and come into my room. I know this won't last forever, but this mom needs sleep.

I have no idea what to do. About a year ago he was watching things on YouTube he shouldn't have been watching. We put an end to that. Didn't help the sleep situation. I've asked him what he needs to sleep in his own room, and provided what he's asked for (making sure his closet door is closed, putting curtains up over the blinds). This worked for 2 nights. My husband and I have tried walking him back to his room and sitting with him until he falls back to sleep. This can take 45 min and is super disruptive to our sleep, and he'll be back in our room about an hour later. I truly believe he does this on purpose because he can. I've told him if he doesn't sleep in his own bed he can't use electronics the next day - he stayed in his room for 2 nights and then basically decided he didn't care. Short of locking my bedroom door l, I don't know what to do. I'm an awful sleeper, so when he wakes us up coming in our room it takes me like an hour to go back to sleep. So really his getting up is super disruptive to EVERYONE. I'm at a loss. I have no idea what to do. And I'm conflicted, bc I love his snuggles and I know there will come a day he doesn't want to sleep/snuggle with us but also I need sleep.

There are other things we've tried to encourage him to stay in his room but in order to not make this post way too long I'll share them as needed. Thanks for reading/advising.