Hydrogel materials offer many advantages for chemical and biological sensoring due to their response to a small change in their environment with a related change in volume. Several designs have been outlined in the literature in the specific field of hydrogel-based optical sensors, reporting a large number of steps for their fabrication. In this work we present a three-dimensional, hydrogel-based sensor the structure of which is fabricated in a single step using thermal nanoimprint lithography. The sensor is based on a waveguide with a grating readout section. A specific hydrogel formulation, based on a combination of PEGDMA (Poly(Ethylene Glycol DiMethAcrylate)), NIPAAm (N-IsoPropylAcrylAmide), and AA (Acrylic Acid), was developed. This stimulus-responsive hydrogel is sensitive to pH and to water. Moreover, the hydrogel has been modified to be suitable for fabrication by thermal nanoimprint lithography. Once stimulated, the hydrogel-based sensor changes its topography, which is characterised physically by AFM and SEM, and optically using a specific optical set-up.