A theoretical analysis of a fiber-optic photonic-bandgap (PBG)-based nanorefractometer is presented. Changes up to 11.2 dB in the optical output power in an index of refraction range of 1.7 with a sensitivity of 1.5·10-4 have been demonstrated. The design is based on a one-dimensional PBG structure with two defects, which originates two defect states inside the bandgap. These states correspond to two localized modes in the defects. By selecting adequate parameters, the frequency of one of the localized modes can be fixed at the same time that its peak amplitude varies with the refractive index of the defect associated to the other localized mode. The refractive index of the defect associated to the localized mode that has been fixed in frequency remains constant. This enables a detection scheme based on a simple photodetector instead of an optical spectrum analyzer, as usual. The thickness of the defect whose refractive index varies determines the variation range of the transmitted power amplitude peak of the localized mode fixed at a concrete frequency. In addition, an analysis of the nonlinear dependence on the refractive index of the peak-transmitted power of the localized mode fixed at a concrete frequency is presented.