A 3D Cd II -based metal–organic framework, [CdL ene N 3 ] n (namely complex 1), was prepared by heating CdCl 2 , NaN 3 , and 4-(4-cyanostyryl)pyridine (L) in a mixed solution of i-PrOH and H 2 O at 165 °C for 72 h. Interestingly, cyano and azide groups can react with each other in suit to generate tetrazolate groups during the synthetic process, which can be confirmed by the single crystal X-ray diffraction analysis. On account of its excellent stability and luminescent property, the as-synthesized 1 is an outstanding luminescent sensor material for nitrofurantoin (NFT) in water. The K sv value of complex 1 toward NFT is ~1.4 × 10 4 M −1 with a good R 2 value of 0.9983. More importantly, the resultant crystals are easily recollected and reused at least five cycles.