A total internal reflection optical switch comprising a heterojunction transistor having a self-aligned ion implanted source, an ohmic gate, a mesa, and three self-aligned waveguides, said waveguides being defined with the same photolithographic mask as the ohmic gate to insure precise alignment, a single quantum well under the ohmic gate, the single quantum well being comprised of undoped, narrow bandgap material bound on both sides by two regions of p-doped, wide bandgap material, both of said p-doped regions have symmetrically graded bandgaps, being most narrow next to the quantum well and increasing out to a wide and constant value away from the quantum well, a highly n-doped and totally depleted charge sheet in the wide bandgap material, very near the gate side of the quantum well heterojunction, said charge sheet inducing a voltage controllable inversion channel within the quantum well, said three waveguides comprising a single input port and two output ports, said two output ports comprising a straight through optical path and a reflection optical path, a source of optical energy applied to said single input port, the energy from said source of optical energy being directed into and out of the region under the ohmic gate by said waveguides, a total internal reflection being created in said switch which routes the optical energy to said reflection optical path by inducing a change in refractive index under the ohmic gate by means of a voltage applied between the ohmic gate and the source electrode.