A facile hydrothermal method was used to grow a very thin film of NiO nanoworms on an anodized Ni foil for the first time. The prepared NiO nanoworms were used as a sorbent in the thin-film microextraction (TFME) method. Before the hydrothermal process, the Ni foil substrate was anodized. The prepared film was used to analyze caffeine as a model compound in various caffeine beverages and urine samples via TFME. After extraction, the extracting film was eluted using methanol to desorb the target analyte. The extracted analyte was then analyzed by high-performance liquid chromatography-ultraviolet detection (HPLC-UV). The Plackett–Burman design was used for screening the experimental factors of interest in TFME. Thereafter, the effective factors were optimized using central composite design (CCD). Under optimum conditions, the linear dynamic range (LDR) of the method was between 0.5 and 500 μg L−1 with coefficient of determination (r2) of 0.9954. The limit of detection (LOD) was 0.07 μg L−1, and the limit of quantification (LOQ) was 0.25 μg L−1; the relative standard deviation (RSD) values of the method for the analyte at 10 μg L−1 were 5.4% (as intra-day RSD) and 5.8% (as inter-day RSD). The film-to-film reproducibility for three prepared films was 7.3%