The use of drug delivery systems for the gastrointestinal tract has been faced with a number of drawbacks related to their prolonged use. Here, the authors develop a drug-loaded hydrogel with high strength to withstand long-term gastrointestinal motility and can be triggered to dissolve on demand.