Facebook said its position had not changed since last year, when it said: “We oppose any efforts to force travelers at the border to turn over their private account information, including passwords.”

Along with the social media information, visa applicants will be asked for past passport numbers, phone numbers and email addresses; for records of international travel; whether they have been deported or removed, or violated immigration law, in the past; and whether relatives have been involved in terrorist activities.

“Maintaining robust screening standards for visa applicants is a dynamic practice that must adapt to emerging threats,” the State Department said in a statement. “We already request limited contact information, travel history, family member information, and previous addresses from all visa applicants. Collecting this additional information from visa applicants will strengthen our process for vetting these applicants and confirming their identity.”

Millions of people each year complete the online application for a nonimmigrant visa, known as the DS-160. It takes about 90 minutes to fill out, according to the department.

The San Bernardino, Calif., terrorist attack in 2015, which killed 14 people, focused attention on immigrants’ social-media use, after officials acknowledged that they had missed signs of online radicalization in an online-messaging platform used by the husband and wife who carried out the attack.

Last year, John F. Kelly, who was then the secretary of homeland security and is now Mr. Trump’s chief of staff, told members of Congress that his department was considering asking visitors for passwords and access to online accounts.

“We want to get on their social media, with passwords,” Mr. Kelly told members of the House Homeland Security Committee. “If they don’t want to cooperate, then you don’t come in.”