The use of electrospinning has received much attention in the production of nanofiber webs due to its advantages such as flexibility and simplicity. The direct electrospinning of nanofibers in an aligned or twisted form and the production of nanofiber yarns can turn nanofibers into woven fabrics, which leads to an increase in the diversity of nanofiber applications and improves their end-use possibilities. In this work, a victorious nanofiber yarn spinning system was used with the help of a rotating funnel. Yarn formation was studied using a composited polyacrylonitrile (PAN)/MXene polymer solution ejected from two oppositely charged nozzles. Finaly their application for packed-in-tube solid-phase microextraction of β-blocker drugs from biofluids was demonstrated. The separation and quantification of analytes were performed by HPLC-UV instrument. The 3D-yarn PAN/MXene sorbent exhibited high flexibility, porosity, sorbent loading, mechanical stability, and a long lifetime. The characterization of the final nanofiber was carried out utilizing Fourier-transform infrared spectroscopy, field emission scanning electron microscope, energy-dispersive X-ray mapping, transmission electron microscope and X-ray diffraction analysis. Various parameters that affect the extraction efficiency, such as extraction time, pH, ionic strength and flow rate of sample solution, and type, volume and flow rate of eluent, were investigated and optimized. Under optimized conditions, the limits of detection were obtained in the range of 1.5–3.0 μg L−1. This method demonstrated appropriate linearity for β-blockers in the range of 5.0–1000.0 μg L−1, with coefficients of determination greater than 0.990. The inter- and intra-assay precisions (RSDs, for n = 3) are in the range of 2.5–3.5%, and 4.5–5.2%, respectively. Finally, the validated method was put in an application for the analysis of atenolol, propranolol and betaxolol in human urine and saliva samples at different hours and acceptable relative recoveries were obtained in the range of 89.5% to 110.4%.