Edit: How to use good wiring methods for a closet light switch with a door reed switch or plunger. The key is work in low voltage.
First, keep in mind Code has a thing or two to say about closet lights, so the heat of the light doesn't start a fire, and even more about mains wiring in closets.
Option 1: use low voltage lighting off a transformer or power supply located at the mains supply. But watch it, low voltage means high current!
Option 2: bring mains power to the light fixture, mount an extension octagon box on the fixture box, and something like a RiB or Aube transformer-relay combo device. These either mount in a knockout on the junction box, or on the cover of a 4" square junction box. They are made for this use exactly.
The RiB's cost as little as $16 but most of this equipment puts the mains wiring inside the junction box and the low voltage wiring outside as code requires. RiB does not. Ask a local electrical supply house (not big-box store) if they have any magic junction boxes to solve this.
See where it says "Sold By" and the next word is not Amazon? This is Amazon Marketplace, which is on the same level as eBay and AliExpress. That gomi doesn't even come close to meeting the standards for equipment used in mains wiring. In NEC, this is covered in Article 110, particularly 110.3 where equipment must be listed by an independent testing lab such as UL, CSA or German TUV. (note CE is not a testing lab.)
Mind you, *components** are not equipment. If it's sold at Digi-Key or Mouser, it's a component. You use equipment, not components, in mains wiring. So what does a UL mark on a component mean? It means UL has already done performance, insulation, toxic smoke etc. testing and will not need to redo those tests when certifying your equipment.
Equipment used in mains electric is sold at your friendly neighborhood electrical supply house, which are mostly local shops but include Greybar and City Electric. Home Depot, Lowes and Menards have some of this stuff.
Your item there looks like a component. But setting aside that, it doesn't provide any possible way to wire it using any safe wiring methods in NEC chapter 3.
It's fit for using inside of equipment, where chapter 3 does not apply: say you manufacture a relay box and want an interlock to shut off power if the cover was removed. But the equipment would need to be listed separately.
Another option for its use is low-voltage wiring. The component is certified (by who? magic elves?) for 120V, but you're allowed to use it at lower voltages**. Code is much more relaxed when there's 5 volts on a wire instead of 120. Low voltage wiring is covered in a different chapter, and devices which look like this (but are listed) are used in things like security systems all the time.
This would allow you to wire it using the informal rules for thermostat and intercom wiring, put 5V or 12V on it, and use that to switch your mains load, either with a relay or smart switch magic.
And by "it" I mean a quality unit sourced from a security-system supply house, Mouser, McMaster-Carr, etc. This online dreck is often wildly overpriced, in this case I found a similar one at West Marine (!!!)* for half the price, free shipping and UL listed. SMH. Use Marketplace/eBay/Ali for inspiration but get listed versions of it, often cheaper, often at local shops.
* West Marine is infamous for overpricing already-overpriced marine gear.
** in fact, putting anywhere near spec voltage on something that "fell off a truck in Shenzhen" is itself crazy.
*** not even on Amazon Prime, Prime requires the manufacturer stock up Amazon warehouses, and Amazon charges a mint for that, and that is passed onto you in the price.