Crating CAN be great, but you need to approach it in the right way.
Do t use the crate as a punishment/time-out for bad behaviour.
Don't expect your puppy/dog to take to it straight away. Read up on positive crate training.
If possible, especially to begin with, site the crate within a room that you can also close off if needed (utility, etc).
On recommendation from a dog behaviourist, I enclosed my girl’s crate. I bought a couple of packs of blackout lining from The Range and used them to cover all sides apart from the entry side. This was so that, when in there, she wasn’t distracted/alerted by activity going on outside the window etc. No distractions meant that she didn’t feel the need to bark at passers-by etc - she had a calming safe space.
She had the run of downstairs, but would happily toddle off to her crate when she felt like it. I was “lucky” that it was in a room that I could gate off, but she was ok with that. I never actually shut the door of the crate, but k ew she was still “contained”.
There will be lots of info online re crate training. The most basic is to build it up slowly re time in the crate. Another is to reward your pup/dog for going in. Always make sure they have a high level treat/chew/toy when going in. Do not lavish them with praise/affection when they come out. They need to associate their reward/treat with being in there, not with being let out. Have a look at (age appropriate) antler bones - they don’t rot, last ages and alleviate boredom as something pretty non-destructive to chew.
Also, make sure you get the right size of crate. They need to be able to comfortably standup, turn around etc. my girl was a giant breed, had to ensure that she felt comfortable within it.
If you have a pup and are considering crating in line with toilet training, I’d say don’t - or research very carefully how you do so. You can’t expect to shut a pup in overnight hoping that it won’t soil itself. They have no control over their bodily function until they start to mature a bit. So, for toilet training, you need to research toilet training methods and bear with them - a crate is not the answer for that.
A crate really can be a great, safe space for a dog - one that it takes itself off to willingly when it wants to. But you need to put the time and effort into making it this way - you can’t just pop them in there and expect them to be ok with it.