I would like to write “I live on the campus”. I have written it as
J'habite dans le campus
But I have found here “vivre sur le campus” as “live on campus”. I would like to know if my translation is correct.
It is much more common to write and say "J'habite sur le campus.". However, you do find "dans le campus" and it is not really incorrect (ngram).
"Sur" is the préposition generally used for all the usual constructions (ngram);
"Au campus" (à le campus) is used but it seems to be essentially limited regionally to Africa (ref).