Covalent organic frameworks (COFs) with metal complexing ligand including COF-phen and COF-bpy have been designed and prepared, which can complex with Sn4+ to form COF-phen-Sn and COF-bpy-Sn, respectively. In this work, the metal ion complexed COFs are successfully employed as ideal precursors for the preparation of composite materials SnO2 @NCNR-x with nano SnO2 embedded within the rod-like N-doped carbonaceous materials. When employed as anode materials for lithium ion batteries (LIBs). SnO2 @NCNR-1 exhibited high reversible specific capacity (694.2 mA g−1 at 100 mA after 200 cycles, 506.5 mAh g−1 at 0.5 A g−1 after 600 cycles) owing to its high specific area, highly dispersed SnO2 nanoparticles and improved conductivity, recommending SnO2 @NCNR-1 to be a prospective candidate for LIBs.