TITLE: Is there a universal property of $\text{Spec}(-)$?
QUESTION [10 upvotes]: I've heard it been said that the construction of Spec$R$ is a canonical way of taking the ring $A$ and producing a locally ringed space with $A$ as the ring of global sections. This is certainly informal; but is it correct in some technical sense? If it was, we might expect to find $\text{Spec}(-):\text{Ring}^{op}\to\text{LRSpace}$ (or indeed $\text{Spec}(A)$) characterized by some universal property. So I wonder: is this so?
Sincerely, Eivind

REPLY [11 votes]: The natural bijection
$$
\mathrm{Hom}_{\mathrm{LRS}}(X, \mathrm{Spec}(A)) \cong \mathrm{Hom}_{\mathrm{CRing}}(A,\Gamma(X, \mathcal{O}_X))
$$
might be the universal property of $\mathrm{Spec}(A)$ you are looking for. Here $(X,\mathcal{O}_X)$ denotes a locally ringed space which is not necessarily a scheme.