Let $G$ be a free group with a base $S$.
How do I prove that $G=\langle S\rangle $ only using universal property?
Here's how I proved this. Let $F(S)$ be the free group on $S$ constructed via reduced words on $S$. This construction shows that $F(S)$ is generated by $S$. Since $S\subset F(S)$ and $S\subset G$, there is a group isomorphism between $F(S)$ and $G$ which keeps $S$ fixed. Hence $G=\langle S \rangle$.
However, I think this proof is bad. How do I prove that using only universal property?
My definition for free group:
Let $G$ be a group.
Then, $G$ is free iff there exists $S\subset G$ such that for any group $H$ and a function $f\in H^S$, there exists a unique $\phi\in Hom(G,H)$ such that $\phi\upharpoonright S=f$
The map of sets $f:S \hookrightarrow G$ factors over the group $\langle S \rangle$, so by the universal property the identity homomorphism $G \to G$ obtained from $f$ factors over $\langle S \rangle \hookrightarrow G$. In particular $\langle S \rangle \hookrightarrow G$ is surjective.