Highly effective recognition and detection of metal ions, anions and organic small molecules from water have attracted remarkable attention for environmental safety. Herein, a novel Cd-based coordination polymer [Cd(HL)(4,4′-bipy)(H2O)]n (1) and a metal–organic framework {[Cd3(L)2(bip)2(H2O)3]·5H2O}n (2) have been synthesized by employing a semi-rigid tricarboxylic acid ligand (H3L) and different N-containing ligands under hydrothermal conditions, where H3L = 3-[(1-carboxynaphthalen-2-yl)oxy] phthalic acid, 4,4′-bipy = 4,4′-bipyridine, bip = 1,4-di(pyridine-4-yl) benzene. Single crystal X-ray analysis reveals that 1 presents a 4-connected 2D network structure with a Schläfli symbol of (44·62),whilst 2 possesses a (3,4,4)-connected 3D framework with a Schläfli symbol of (4.82)2(42.82.102)(8.104.12). Furthermore, 1 and 2 have been characterized by elemental analyses, FT-IR, powder X-ray diffraction, thermogravimetric analyses, fluorescence and UV spectra, exhibiting good stability and excellent photoluminescence properties. 1 and 2 have been chosen as fluorescent probes to sense different target analytes, showing an obvious selective recognition response to Co2+, Ag+, Cr2O72-, CrO42-, nitrobenzene and nitromethane through luminescence quenching effects in aqueous solutions. The possible fluorescence quenching mechanisms are studied in detail, revealing that fluorescence quenching is mainly related to weak interactions, competitive energy absorption and electron transfer.