PEX should not run directly to an electric or tankless water heater, but it can run to a copper riser 18 inches or more in length, coming directly from the water heater. But be advised that the PEX tubing must be 6 inches away from the exhaust vent of the heater.