When you apply for U.S. citizenship, the government wants to make sure you have closer ties to the United States than to any other country. One of the ways it does this is through rules relating to your residence and presence in the U.S., both past and present. If you have are or have been absent from the United States since becoming a permanent resident (a green card holder), you need to be aware of five different citizenship rules that most people must comply with.
(This article doesn't discuss any of the ways you might be exempt from some or all of these rules.)
WARNING: Issues about time spent outside the U.S. are of particular concern to the many green card holders who became stranded outside the country due to the coronavirus (COVID-19) pandemic. Some might have been unable to arrange travel home, or worried about becoming ill when traveling, or ill themselves. There is no blanket rule excusing such absences, but you will at least have an opportunity to explain that you didn't intend to break the continuity of your residence (as described below).
You can't apply to become a U.S. citizen unless you're a permanent resident of the United States. When you apply, U.S. Citizenship and Immigration Services (USCIS) will check to make sure you didn't abandon your permanent residence at some point by spending too much time outside the United States.
USCIS can decide you abandoned your permanent residence if you moved to another country intending to live there permanently, or if you left the United States and remained outside the country for a long time.
There's no particular period of time that you can stay outside the United States and feel safe. It's more a question of whether you intended your trip to be temporary. Usually any trip for six months or less won't be questioned.
USCIS might think you abandoned your permanent residence if you took a trip for more than six months, and you really have some explaining to do if your trip lasted more than a year. USCIS will look at the reason for your trip, how long you intended to be gone, and what caused you to be gone so long. You can also abandon your permanent residence by multiple trips, no matter how long, if you don't really spend much total time in the United State at all.
The general rule is that you must have five years of continuous (unbroken) residence in the United States right before applying for citizenship, and also before your oath ceremony.
The rule changes to three years for people who are married to and living with a U.S. citizen spouse. If you broke your continuous residence by living outside the United States, you will have to wait to apply for citizenship. (For details, see When Can I Apply for U.S. Citizenship?)
To have continuous residence, your permanent dwelling place must have been in the United States. USCIS looks at the place you actually lived. If you lived overseas, it doesn't matter if you considered your main residence to be in the United States or if you always had plans to move back.
USCIS will presume that you broke your continuous residence if you were gone from the United States for more than six months during the five years before applying. You can, in the course of applying for citizenship, convince USCIS that your absence didn't break your continuous residence. To do so, you'll want to show evidence that, for example, you kept your job in the United States and didn't take a job overseas when you were gone, that your family stayed in the U.S. when you were gone, that you kept a place to live in the U.S. for when you returned, and more about your ties to the United States.
If you were gone for a continuous period of one year or more during the five- (or three-) year period, your continuous residence was broken. You can't try to convince USCIS otherwise. You'll have to wait until you've been back in the U.S., living there continuously for four (or two) years and a day before applying for citizenship. (You don't have to wait the full five (or three) years, because even if you leave again, you can't possibly be gone for a whole year by the time you apply. But it's best not to leave again for more than six months.)
You must be physically present in the United States during at least half of your five or three years or required continuous residence. That's a minimum of two and a half years before you apply and before you take your oath, or one and a half years for spouses of U.S. citizens.
The days do not have to be continuous in any way. USCIS is just going to look at the last five (or three) years and count the number of days you spent inside the United States. Even if you preserved your continuous residence by not staying outside the U.S. for more than six months or a year at a time, multiple shorter trips could be a problem for the physical presence requirement.
The day you leave the U.S. and the day you return are counted as days of physical presence within the U.S. for citizenship purposes.
What if you're stranded outside the U.S., and the total days of your absence are about to add up to have of your required physical presence time? One possibility is to quickly submit your naturalization application from abroad, so as to lock in your time as of when your application is received.
When you apply for citizenship, you must have lived in your state or in the USCIS service district where you apply for at least three months. If you've been permanently living outside the United States, you can't immediately apply for citizenship when you move back.
You need to decide where you want your citizenship interview and oath ceremony to take place, and live in that state or USCIS service district for at least three months. If you move later, you can ask that your interview location be changed.
If you're coming back to your former residence in the U.S. after having been outside the country for less than a year, you can apply right away, as long as you had been living there (or in that state or USCIS service district) for three months before you left the United States.
If you're going to school outside your state or USCIS service district, you can apply for citizenship where your school is located, or where your parents live, if you're financially dependent on them at the time of filing and during the whole citizenship application process.
After you apply for citizenship, USCIS needs to take your "biometrics" (fingerprints and so forth), interview you, and give you your certificate of naturalization at an oath ceremony. These things must happen in the United States. If you leave the United States after sending your citizenship application, you must come back to complete the application process.
NOTE: Owing to the coronavirus pandemic, USCIS is, as of early 2020, closed for all of the above in-person functions. Even after these reopen, expect delays.