Given two vectors $\vec a$ and $\vec b$, the vector projection of $\vec a$ onto $\vec b$ is:
$$\vec a_{\parallel \vec b}=
\frac{\vec a \cdot \vec b}{\vec b \cdot \vec b}
\vec b$$
The component of $\vec a$ that is perpendicular to this is called the vector rejection on $\hat b$:
$$ \vec a_{\perp \vec b}=\vec a - \vec a_{\parallel \vec b}=\vec a -
\frac{\vec a \cdot \vec b}{\vec b \cdot \vec b}\vec b
$$
If $\vec b=\hat b$ is a unit vector:
$$ \vec a_{\perp \vec b}=\vec a -(\vec a\cdot \hat b)\hat b$$
Armed with that geometric knowledge we can address the question. We can capture the index of refraction and wave direction with the wave vector:
$$\vec k_{\alpha}=\mu_{\alpha}\hat n_{\alpha} $$
(with $\alpha\in(i, 1)$ or $\in(r, 2)$).
The fact that the phases of the incident and refracted rays need to match along the boundary (perpendicular to $\vec s$) means that wave vector rejection onto $\hat s$ is continuous across the boundary:
$$\vec k_{r,\perp \hat s} = \vec k_{i,\perp \hat s}$$
or
$$\mu_2 \vec n_{r,\perp \hat s} = \mu_1 \vec n_{i,\perp \hat s}$$
which is Snell's Law.
From here, you go in two directions. First:
$$\vec n_{r,\perp \hat s} = \frac{\mu_1}{\mu_2} \vec n_{i,\perp \hat s}=
\frac{\mu_1}{\mu_2}[\hat n_i-(\hat n_i\cdot \hat s)\hat s]
$$
solves for the transverse component of the unit vector of the refracted wave $\hat n_r$, which can be written:
$$\hat n_r = \left(\begin{array}{c}
n_{r,\perp \hat s} \\ n_{r,\parallel \hat s}\end{array}\right)$$
Here, the 3rd dimension (along $\hat n \times \hat s$) has been suppressed. The remaining basis vectors are in the $n-s$ plane, with $\left(\begin{array}{c}0\\1\end{array}\right)=\hat{s}$ and $\left(\begin{array}{c}1\\0\end{array}\right)$ along $ (\hat n\times\hat s)\times \hat s$.
Sin $\hat n_r$ is a unit vector:
$$ ||\hat n_r||^2 = n_{r,\perp \hat s}^2 + n_{r,\parallel \hat s}^2=1
$$
so that:
$$\hat n_r = \left(\begin{array}{c}
n_{r,\perp \hat s} \\ \sqrt{1-n_{r,\perp \hat s}^2}\end{array}\right)$$
We have a vector expression for the transverse component. Note that:
$$ \left(\begin{array}{c}0\\1\end{array}\right)=\hat s$$
so the vector expression for the longitudinal component is:
$$ \vec n_{r,\parallel \hat s}=
\sqrt{1-n^2_{r, \perp\hat s}}\hat s
$$
Add those together to get:
$$\hat n_r = \frac{\mu_1}{\mu_2}[\hat n_i-(\hat n_i\cdot \hat s)\hat s] + \sqrt{1-n^2_{r, \perp\hat s}}\hat s$$
and substitute:
$$\hat n_r = \frac{\mu_1}{\mu_2}[\hat n_i-(\hat n_i\cdot \hat s)\hat s] + \sqrt{1- \left\Vert\frac{\mu_1}{\mu_2}[\hat n_i-(\hat n_i\cdot \hat s)\hat s] \right\Vert^2}\hat s$$
and turn the crank.
Comment on notation:
Note that all $\hat n_{\alpha}$ are unit vectors. The projection or rejection of that onto another vector $\vec v$ is not necessarily a unit vector, and hence, does't have a hat. So the arrow over the $n$ in $\vec n_{r,\parallel \vec v}$ refers to the resultant vector after vector projection onto $\vec v$, even though the initial vector, $\hat n_r$, was a unit vector.
Meanwhile, the operation of scalar projection/rejection, has neither, e.g. $a=n_{r,\parallel \vec v}$ is a scalar which can converted into a vector a la:
$$\vec n_{r,\parallel \vec v} = a\hat v$$