The invention relates to methods of preparing nicotinamide riboside and derivatives thereof. In an aspect, the invention relates to a method of preparing a compound of formula (I), wherein n is 0 or 1; m is 0 or 1; Y is O or S; R1 is selected from H, substituted or unsubstituted alkyl, substituted or unsubstituted alkenyl, substituted or unsubstituted alkynyl, substituted or unsubstituted aryl, substituted or unsubstituted primary or secondary amino, and substituted or unsubstituted azido; R2-R5, which may be the same or different, are each independently selected from H, substituted or unsubstituted alkyl, substituted or unsubstituted alkenyl, or substituted or unsubstituted alkynyl, and substituted or unsubstituted aryl; and X− is an anion, selected from an anion of a substituted or unsubstituted carboxylic acid, a halide, a substituted or unsubstituted sulfonate, a substituted or unsubstituted phosphate, a substituted or unsubstituted sulfate, a substituted or unsubstituted carbonate, and a substituted or unsubstituted carbamate.