How do I wire my bathroom fan with a new switch?
You need a 12/3 (black/red/white/ground) cable between the fan and the switch location.
You can no longer use a &quot;switch loop&quot; which is how that &quot;used to be done&quot; with a 12/2 cable, because current codes require a neutral at the switch location.
Black (hot)  to the switch, red (switched hot) from the switch to the fan.