The metal oxide nanoparticles (NPs), zinc oxide (ZnO) and nickel oxide (NiO) were synthesized using Sterculia foetida (S. foetida) leaf extract by solution combustion method. The Poly (glutaric acid-co-ethylene glycol-co-acrylic acid (GEA)) hydrogel was prepared using three different monomers such as glutaric acid (G), ethylene glycol (E) and acrylic acid (A). The zinc oxide (ZnO) and nickel oxide (NiO) nanoparticles were introduced into GEA hydrogel and the polymer nanocomposites GEA-ZnO and GEA-NiO were obtained. The UV–visible spectroscopy (UV) peak observed at 275 nm and 360 nm for GEA-ZnO and GEA-NiO polymer nanocomposites. The Fourier Transform Infrared (FT-IR) spectral data obtained at 414 cm−1 confirmed the presence of nanoparticles in the hydrogel. The size of the nanoparticles were confirmed through Scanning Electron Microscopy (SEM) and Transmission Electron Microscope (TEM) analysis. The size of the zinc oxide nanoparticles (ZnO NPs) introduced in GEA-ZnO polymer nanocomposite was 30–35 nm and the size of nickel oxide nanoparticles (NiO NPs) introduced in GEA-NiO nanocomposite was 27–33 nm. The percentage of zinc oxide (ZnO) and nickel oxide (NiO) were reported in Energy Dispersive X-ray Analysis (EDAX) spectrum. Where the percentage of zinc (Zn) is 2.22% and nickel (Ni) is 2.7%. The thermal stability of the nanoparticles in the hydrogel was assessed by Thermo gravimetric analysis (TGA). Beyond 450 °C there was no change in the Thermo Gravimetric Analysis (TGA) peak of GEA-NiO polymer nanocomposite and found with nil weight loss. The antibacterial activity was performed using Staphylococcus aureus (S. aureus) and Bacillus subtilis (B. subtilis) gram positive bacterial strains and Escherchia coli (E. coli) and Klebsiella pneumoniae (K. pneumoniae) gram negative bacterial strains. The gram positive bacteria showed highest antibacterial activity than gram negative bacteria at highest concentration 100 μg/ml towards polymer nanocomposites.