The invention relates to a method for treating a nanofibrillar cellulose hydrogel, wherein the method comprises the steps of: providing a nanofibrillar cellulose hydrogel and subjecting the nanofibrillar cellulose hydrogel to a heat treatment, wherein the heat treatment is carried out by transferring the nanofibrillar cellulose hydrogel through at least one heat exchanger or through at least one insulated holding tube, during which heat treatment the nanofibrillar cellulose hydrogel is kept at a predetermined temperature within the range of 110-150° C. for a period of time in the range of 15 seconds to 20 minutes, wherein the pre-determined temperature and period of time are chosen such that the number of viable micro-organisms in the nanofibrillar cellulose hydrogel is reduced by a factor of at least 103.