Ionic liquid (IL) was incorporated into a zeolitic imidazolate framework-8 (ZIF-8) under mild conditions. (1)-methylimidazole and 1-bromobutane were combined to form the IL inside the pore structure of ZIF-8 using the ship-in-bottle (SIB) method. The IL@ZIF-8 composite has been thoroughly characterized using X-ray diffraction (XRD), Field emission scanning electron microscopy (FESEM), Brunauer-Emmett-Teller analysis (BET), and Fourier transform infrared spectroscopy (FTIR). IL@ZIF-8 composite was used as a new adsorbent For the preconcentration and measurement of Cd (II) and Co (II) ions in a variety of sample matrices, such as soil, vegetable juice, and water. This methodology was achieved by integrating vortex-assisted dispersive solid phase microextraction (VA-DSPME) and flame atomic absorption spectrometry (FAAS). Under optimal conditions, the method demonstrated a favorable linear dynamic range within the range of 0.001–2 and 0.008–10 µg mL−1, with a lower limit of detection values of 0. 33 and 2.42 µg/L for Cd (II) and Co (II) ions, respectively. Furthermore, the method preconcentration factor was 25 for both metal ions. The relative standard deviations (RSDs) of this work were found to be below 1.0 % for the concentration of 0.5 µg mL−1.