We propose a microfluidic method to measure the refractive index of liquids. This method is based on the dynamic focusing by a capillary when liquids with different refractive indexes are inserted into it. Fabrication of such a refractometer has been done by encapsulating two fibers and a capillary. A calibration method is proposed.