This is addressed by Social Security on this page: If you leave the United States
“Leaving the United States means leaving the 50 states, the District of Columbia or the Northern Mariana Islands. Usually, if you leave the United States for 30 days or more, you can no longer get SSI.
If you move to Puerto Rico, you are considered to be outside the United States for SSI purposes only. People who live in Puerto Rico cannot get SSI.
If you plan to leave the United States, tell us before you leave. We need to know the date you plan to leave and the date you plan to come back. Then we can tell you if your SSI will be affected.
Once you have been outside the United States for 30 or more days in a row, your SSI cannot start again until you have been back in the country for at least 30 straight days.
There are special rules for dependent children of military personnel who leave the U.S. They may be able to get or apply for SSI while overseas. There also are exceptions for students studying abroad.”