This paper reviews the device physics and technology of optoelectronic devices based on semiconductors of the GaN family, operating in the spectral regions from deep UV to Terahertz. Such devices include LEDs, lasers, detectors, electroabsorption modulators and devices based on intersubband transitions in AlGaN quantum wells (QWs). After a brief history of the development of the field, we describe how the unique crystal structure, chemical bonding, and resulting spontaneous and piezoelectric polarizations in heterostructures affect the design, fabrication and performance of devices based on these materials. The heteroepitaxial growth and the formation and role of extended defects are addressed. The role of the chemical bonding in the formation of metallic contacts to this class of materials is also addressed. A detailed discussion is then presented on potential origins of the high performance of blue LEDs and poorer performance of green LEDs (green gap), as well as of the efficiency reduction of both blue and green LEDs at high injection current (efficiency droop). The relatively poor performance of deep-UV LEDs based on AlGaN alloys and methods to address the materials issues responsible are similarly addressed. Other devices whose state-of-the-art performance and materials-related issues are reviewed include violet-blue lasers, 'visible blind' and 'solar blind' detectors based on photoconductive and photovoltaic designs, and electroabsorption modulators based on bulk GaN or GaN/AlGaN QWs. Finally, we describe the basic physics of intersubband transitions in AlGaN QWs, and their applications to near-infrared and terahertz devices.