A nanomechanical near-field grating device is disclosed which includes two sub-gratings vertically spaced by a distance less than or equal to an operating wavelength. Each sub-grating includes a plurality of line-elements spaced apart by a distance less than or equal to the operating wavelength. A light source (e.g., a VCSEL or LED) can provide light at the operating wavelength for operation of the device. The device can operate as an active grating, with the intensity of a reflected or transmitted portion of the light varying as the relative positions of the sub-gratings are controlled by an actuator. The device can also operate as a passive grating, with the relative positions of the sub-gratings changing in response to an environmentally-induced force due to acceleration, impact, shock, vibration, gravity, etc. Since the device can be adapted to sense an acceleration that is directed laterally or vertically, a plurality of devices can be located on a common substrate to form a multi-axis acceleration sensor.