To make soap, lye serves as an emulsifying agent that allow oil and water to combine in the exothermic process known as saponification. There are two types of lye used in modern soapmaking: potassium hydroxide and sodium hydroxide.
Potassium hydroxide, chemically known as KOH, is used primarily in liquid soapmaking. Sodium hydroxide, chemically known as NaOH, is used primarily in bar soap making. Sodium hydroxide can also be heavily diluted to be used as a pH raising agent in cosmetic formulations. Shave soaps are generally dual lye formulations using both KOH and NaOH.
Lye, in both forms, is a highly alkaline and caustic substance that can cause severe chemical burns to the skin. It is inert in its dry form (granules or flakes) but when added to water, it produces an exothermic reaction (it gets really hot...very fast) that releases bubbles and may appear to boil--which it normal. It also generates fumes which are very irritating to the eyes, nose, and lungs. Goggles, gloves, long sleeves, and a respirator or mask is beneficial in alleviating the effects and irritation. It is common practice to never pour water over lye--always slowly add lye to the water. Before using lye, be sure to familiarize yourself with safe handling and mixing methods, proper storage, and protective gear for your safety and the safety of others who come into contact with your workspace and product.
It is highly recommended that you use a soap calculator to accurately determine the amount of lye needed to saponify your oil base. Here are a few popular choices but more exist: