How are components typically connected to a PCB when they are mounted in an enclosure?
Solder wire to it and the pcb. Heatshrink if needed. Or mount on a small pcb then use wires between the two. Or use connectors/headers on one or both sides. Or use crimps if acceptable.