In this work, we prove some trace theorems for function spaces with a nonlocal character that contain the classical $W^{s,p}$ space as a subspace. The result we obtain generalizes well known trace theorems for $W^{s,p}(Omega)$ functions which has a well-defined $W^{1-s/p, p}$ trace on the boundary of a domain with sufficient regularity. The new generalized spaces are associated with norms that are characterized by nonlocal interaction kernels defined heterogeneously with a special localization feature on the boundary. Intuitively speaking, the class contains functions that are as rough as an $L^p$ function inside the domain of definition but as smooth as a $W^{s,p}$ function near the boundary. Our result is that the $W^{1-s/p, p}$ norm of the trace on the boundary such functions is controlled by the nonlocal norms that are weaker than the classical $W^{s, p}$ norm. These results are improvement and refinement of the classical results since the boundary trace can be attained without imposing regularity of the function in the interior of the domain. They also extend earlier results in the case of $p=2$. In the meantime, we prove Hardy-type inequalities for functions in the new generalized spaces that vanish on the boundary, showing them having the same decay rate to the boundary as functions in the smaller space $W^{s,p}(Omega)$. A Poincare-type inequality is also derived. An application of the new theory leads to the well-posedness of a nonlinear variational problem that allows possible singular behavior in the interior with imposed smoother data on the boundary.