Arabs have immigrated to Detroit, Salvadorans to Washington, Haitians to Miami, Kurds to Nashville. America on this Fourth of July is more than ever a nation of nations.

At least a million immigrants and refugees will pour into the United States this year, perhaps as many as in any year in America's history. About 700,000 will come legally: Soviet Jews, Vietnamese boat people, Cuban political prisoners. Hundreds of thousands more -- no one knows for sure how many -- will sneak over the Mexican border or fly into Dulles Airport as "tourists," and melt into the country as illegal aliens.

Irish potato famine, Hungarian revolution, Indochinese war: the United States, whatever its ambivalence toward the role, has long served as the safety valve for international crises, welcoming more immigrants and refugees than all other free-world nations combined.

American prestige may be dwindling in the eyes of global leaders, but for the oppressed or poverty-stricken people of the world, this country remains an irresistible magnet. Four million a year get in line to come to the United States. Waiting lists for certain types of visas are backed up 11 years.

A Kettering Foundation study in the early 1970s reported that one-third of the people in Latin America want to emigrate here. Indochinese refugees in Thailand overwhelmingly choose the United States over other countries.

The unexpected flood of 117,000 Cuban boat people this spring, coupled with the continuing influx of Indochinese at the rate of 14,000 a month, focused sudden public attention on immigration.

With the freedom flotilla coming ashore in Key West, Fla., the Carter administration woke up to discover it didn't really have an immigration policy. aAs Victory Palmieri, the State Department's refugee coordinator, put it, "We can't afford to take them all in. We can't keep them out."

America has historically welcomed "the huddled masses yearning to breathe free." It is part of the national identity.

"The bosom of America is open to receive not only the opulent and respectable strange," George Washington said in 1783, "but the oppressed and persecuted of all nations and all religions."

Nonetheless, from the 19th Century "yellow peril" scare, prompting laws excluding Asians, to recent efforts of immigration officials to deport Haitians, each new immigrant wave has brought political backlash.

Today, with unemployment nearing 8 percent, the thought of spending millions of dollars to resettle outsiders has rifled many Americans. In California and Texas, lawsuits have been filed to stop the states from granting medical and other social services to illegal aliens.

The reaction is ironic, because every American -- Indians excepted -- is descended from an immigrant, and many quite recently. The 1970 census found that 34.5 million Americans were either foreign-born of had one or more foreign-born parents.

While some unions complain that illegal aliens and new immigrants steal jobs from American workers, studies show that many of the jobs they take are low-paying ones that Americans don't want -- domestics, dishwashers, lettuce pickers. Entrepreneurial Cubans are credited with reviving Miami's economy in the 1960s -- creating more jobs for everyone. Soviet Jews have rejuvenated Brooklyn neighborhoods that were turning into slums.

Some economists see an increase in immigration as a boon. Because of the recent slide in the American birth rate, the number of workers in the U.S. labor force is expected to decline, beginning in 1982, as fewer young workers come of age.

One thing has changed dramatically since the years when Ellis Island served as the gateway to America for millions of refugees traveling steerage across the oceans. Unlike their predecessors, the new immigrants are increasingly from Third World countries, challenging American society to broader racial and cultural tolerance.

Meanwhile, attitudes have changed in the past two decades. The idea of the melting pot, in which all nationalities would blend into a homogeneous stew, is no longer fashionable. Ethnic has become chic.

American women dress in Mexican skirts and Indian shawls, cook with woks and send their children to bilingual schools. Ethiopian, Afghan and Vietnamese restaurants are the rage in Washington and other big cities. Arab bread is sold in the Safeway. The most popular Bicentennial event in small midwestern towns four years ago was the ethnic festival.

Immigrants are more inclined than ever to cling to their heritage. Spanish-speaking Mexicans, Puerto Ricans and Cubans have created citites within cities in such places as Miami and San Antonio. Theirs is a culture that doesn't wash away with the passage of generations, a culture that demands equality with Anglo America.

In Los Angeles, where 50 percent of kindergarten children claim Spanish as a first language, all police cadets are required to take six months of conversational Spanish. Miami blacks complain they can't get jobs because they don't speak Spanish.

But every ethnic group experiences the pangs of culture clash, the pull of its American future and the tug of its past, whether the group be composed of Russian Jews, Hmong tribesmen or Cape Verdeans from West Africa.

And for each group the experience is vastly different. The Cubans, who grew up playing baseball and selling cigars to wealthy Americans, have an easier time adapting than the Hmong, who lived isolated from the world in the mountain villages of Laos.

Virtually every group reports family tensions exacerbated by the quicker adaptability of the young and the nostalgia of the old. Vietnamese parents complain that their children talk back to them, a habit learned from American friends. Cuban parents complain of the sexual freedom of American youth. Young Cape Verdeans, whose parents think of themselves as Portuguese, now call themselves Afro-Americans.

In the eyes of Conrad Tauber, a census expert, becoming American can mean going full circle. "The first generation tries to maintain its culture," he has said. "The second generation -- kids born of foreign parents -- reject it as much as they can. The third generation is still somewhat resentful of ethnicity, but the fourth generation is proud of it. They can stage a Norwegian festival and dress up in folk costumes and go back to being good Americans the next day."