You have to be VERY careful with melatonin. It’s a hormone. Your body produces it naturally. If your body isn’t producing enough, supplementing can be a Godsend. Your body can, however, become reliant on that supplementation and self-recovery can be very difficult, like withdrawal-level symptoms.
I’ve taken melatonin frequently for years. I don’t recall the details, but my doctor told me when he recommended it that it’s a different class than what we normally think of as ‘hormones’and their action.
I’ve never had any unusual side affects or withdrawal. The most that happens is ease in falling asleep and sometimes unusual dreams. I’m not groggy or anything like that the next day.