The typical range worldwide is somewhere between three and ten years of continuous legal residence, with around five being the most common benchmark. Continuous is the operative word: most systems limit how many days per year you can spend abroad, and a long absence can reset the clock entirely.
Not all residence counts equally. Time on work and family visas almost always counts in full. Student years are often discounted, counted at half value, or excluded altogether depending on the country. Tourist stays virtually never count anywhere, since they are visits rather than residence. Time spent waiting for a decision or in irregular status is usually excluded too.
Some routes shortcut the standard timeline: marriage to a citizen, high-skill or investor categories, and refugee status often carry shorter qualifying periods. Because the counting rules are precise and unforgiving, pull the exact requirements from the immigration authority's website early and plan your visa history around them rather than discovering at year five that two years did not count.