Many metals such as the alkali metals react directly with the electronegative halogens gases to salts.
Salts form upon evaporation of their solutions. Once the solution is supersaturated and the solid compound nucleates. This process occurs widely in nature and is the means of formation of the evaporite minerals. 
Insoluble ionic compounds can be precipitated by mixing two solutions, one with the cation and one with the anion in it. Because all solutions are electrically neutral, the two solutions mixed must also contain counterions of the opposite charges. To ensure that these do not contaminate the precipitated ionic compound, it is important to ensure they do not also precipitate. If the two solutions have hydrogen ions and hydroxide ions as the counterions, they will react with one another in what is called an acid–base reaction or a neutralization reaction to form water. Alternately the counterions can be chosen to ensure that even when combined into a single solution they will remain soluble as spectator ions.
If the solvent is water in either the evaporation or precipitation method of formation, in many cases the ionic crystal formed also includes water of crystallization, so the product is known as a hydrate, and can have very different chemical properties compared to the anhydrous material.
Molten salts will solidify on cooling to below their freezing point. This is sometimes used for the solid-state synthesis of complex ionic compounds from solid reactants, which are first melted together. In other cases, the solid reactants do not need to be melted, but instead can react through a solid-state reaction route. In this method, the reactants are repeatedly finely ground into a paste and then heated to a temperature where the ions in neighboring reactants can diffuse together during the time the reactant mixture remains in the oven. Other synthetic routes use a solid precursor with the correct stoichiometric ratio of non-volatile ions, which is heated to drive off other species.
In some reactions between highly reactive metals (usually from Group 1 or Group 2) and highly electronegative halogen gases, or water, the atoms can be ionized by electron transfer, a process thermodynamically understood using the Born–Haber cycle.
Salts are formed by salt-forming reactions
*A base and an acid, e.g., NH + HCl → NHCl
*A metal and an acid, e.g., Mg + HSO → MgSO + H
*A metal and a non-metal, e.g., Ca + Cl → CaCl
*A base and an acid anhydride, e.g., 2 NaOH + ClO → 2 NaClO + HO
*An acid and a base anhydride, e.g., 2 HNO + NaO → 2 NaNO + HO
*In the salt metathesis reaction where two different salts are mixed in water, their ions recombine, and the new salt is insoluble and precipitates. For example:
*: Pb(NO) + NaSO → PbSO↓ + 2 NaNO