Gamma-Ray Integrated Detectors (GRID) mission is a student project designed to use multiple gamma-ray detectors carried by nanosatellites (CubeSats), forming a full-time all-sky gamma-ray detection network that monitors the transient gamma-ray sky in the multi-messenger astronomy era. A compact CubeSat gamma-ray detector, including its hardware and firmware, was designed and implemented for the mission. The detector employs four Gd2Al2Ga3O12 : Ce (GAGG:Ce) scintillators coupled with four silicon photomultiplier (SiPM) arrays to achieve a high gamma-ray detection efficiency between 10 keV and 2 MeV with low power and small dimensions. The first detector designed by the undergraduate student team onboard a commercial CubeSat was launched into a Sun-synchronous orbit on October 29, 2018. The detector was in a normal observation state and accumulated data for approximately one month after on-orbit functional and performance tests, which were conducted in 2019.