You can store an Photos library on an external or removable hard drive just the same as you can on your computer’s built-in hard drive. To create a new library, follow the normal procedure for creating a new library, and choose the external drive as the location for the library. If you have an existing library that you would like to store on your external drive, use the “Duplicate Library” command in the File menu. You will be given a choice of where to duplicate the library to, at which point you can choose the external hard drive that you’d like to copy the library to. Once you’ve created or copied your library on the external drive, you can then open it up just like any other Photos library.
Apple recommends that you store your Photos library on a Mac formatted drive (either MacOS Extended or APFS), and recommends against using SD cards and USB flash drives, as well as network drives. In practice, on macOS Catalina and later a Photos library can be stored on a NAS as long as you’re connecting via the SMB 2/3 protocol, and not Apple’s older AFP protocol which it has now deprecated. Photos is not optimized for working over a network, so working with a library there on a day to day basis will likely be slow, and the addition of network access gives one more possible way for data corruption to occur. We recommend working with your libraries on locally attached disks whenever possible and using a NAS primarily for archiving and/or backups. As always, you should make sure you have an additional backup of the library elsewhere as well.