Nanocantilevers operate based on the principles of mechanical resonance and surface stress. When a force, such as a chemical interaction or a change in mass, is applied to the cantilever, it causes the cantilever to bend or oscillate. These mechanical changes can be detected and measured with high precision, often using optical methods or piezoelectric sensors.