How long do I need to have lived in the UK before applying?

The required period depends on your immigration status and the route under which you are applying. Most applicants must first obtain Indefinite Leave to Remain or settled status before becoming eligible for naturalisation.