  Using a completely covariant approach, we discuss the role of boundary
conditions (BCs) and the corresponding Gibbons--Hawking--York (GHY) terms in $
\mathit{f}(\mathit{R}) $-gravity in arbitrary dimensions. We show that $
f(\mathit{R}) $-gravity, as a higher derivative theory, is not described by a
degenerate Lagrangian, in its original form. Hence, without introducing
additional variables, one can not obtain consistent BCs, even by adding the GHY
terms (except for $f(\mathit{R})=R$).
  However, following the Ostrogradsky approach, we can introduce a scalar field
in the framework of Brans-Dicke formalism to the system to have consistent BCs
by considering appropriate GHY terms. In addition to the Dirichlet BC, the GHY
terms for both Neumann and two types of mixed BCs are derived. We show the
remarkable result that the $f(\mathit{R})$-gravity is itself compatible with
one type of mixed BCs, in $D$ dimension, i.e. it doesn't require any GHY term.
For each BC, we rewrite the GHY term in terms of Arnowit-Deser-Misner (ADM)
variables.
