As a hybrid home and handheld game console, the Nintendo Switch is designed to be easily used in just about any setting — and for a decently long time at that. By Nintendo's own estimates, a fully-charged Switch battery can last anywhere from 4.5 to 9 hours of continuous gameplay, depending on the graphical and processor intensity of the specific games you're playing. Of course, as with any handheld device, that battery doesn't last forever.
The longer you own a Switch console, and the more wear and tear you subject your battery to, the quicker it tends to deplete its charge. If your battery starts to lose its charge too quickly in handheld mode, then you may be tempted to try and open the console up to replace it.
Nintendo doesn't advise customers to do this, as the battery isn't designed to be easily removed. It suggests instead that you send your Switch in for repairs, but not everyone has the time or patience for that. The question then becomes whether or not it is possible to replace your Switch's battery wholly on your own.
Possible, but not advisable
In the strictest sense, it is possible to remove and replace the battery in your Nintendo Switch on your own at home. However, doing so isn't exactly advisable unless you've got a few prerequisites.
Firstly, if your Switch is still in warranty, opening the cover would immediately void it. If your Switch experiences any other kind of hardware problem, Nintendo won't help you. If you've already voided your warranty in some other way, then a DIY battery replacement isn't as big of a deal.
Secondly, Nintendo doesn't actually sell replacement batteries, so you'd need to source one from a third-party. Companies like iFixit do offer replacement Switch batteries, as well as tools and instructions for installation. It is worth noting that this costs money — as opposed to a Nintendo in-warranty repair, which is free. Nintendo does offer out-of-warranty repair services, but you'll need to get an estimate/quote on the service to know the repair cost.
That brings us to the third point: unless you've already got some basic DIY knowledge, a battery replacement may be a bit too difficult for you, even with instructions. This is not something you should attempt unless you already have experience with small electronics maintenance and handling delicate components.
If you need to have your Switch battery fixed immediately, and don't mind shelling out for the parts, then you can perform the fix at home — as long as you know how. Otherwise, if you're still in warranty, let Nintendo take care of it.