This fall, nearly half a million international students will begin or return to STEM degree programs at U.S. colleges and universities. If you’re among them, congratulations — look forward to being wooed by talent-hungry U.S. tech firms when you graduate. But there’s bad news, too: Under current immigration rules, switching from a student visa to an employment visa can be tricky, so it’s important to understand what’s required and how the latest policy upheavals could impact your journey.

In theory, it’s a great time to be a STEM graduate. U.S. STEM jobs are expected to grow by nearly 11% — or about 10.3 million positions — between 2016 and 2026, faster than all U.S. occupations. In practice, however, it can be tough for international students to secure permanent residence in the United States. The H-1B skilled-worker visa system is badly clogged; a federal lawsuit could slam the door on many STEM graduates, and the White House is shaking up both the skilled-worker and student visa systems.

But don’t despair: There’s still a pathway to a future in the United States — you just might face a bumpy ride. Whether you’re starting your studies or preparing to graduate, it’s crucial to understand your options.

Getting an employment-based visa

An employment-based green card requires an executive-level job, a truly extraordinary résumé, or an employer willing to pony up thousands of dollars in fees and labor-certification costs. Because it’s hard to get a green card, most international STEM students aim for an H-1B visa, which lets you work for a specified U.S. employer for up to six years. It’s not a permanent solution, but it can be a useful launchpad for your career.

Even getting an H-1B isn’t easy, though. There’s a hard cap on H-1Bs: This year, there were more than 200,000 applicants vying for just 85,000 visas. Recipients are selected via lottery, and while you could land an H-1B on your first attempt, many tech workers have to try again — and again, and again — before they finally get lucky.

In the meantime, international students typically start out using the temporary work authorization through their student visa until they transfer to an H-1B.

Let’s dig into the details of what’s allowed under your student visa:

If you’re on an F-1 visa

The F-1 student visa is one of the main on-ramps to the U.S. tech sector for foreign-born workers. That’s largely thanks to Bush- and Obama-era changes that expanded the Optional Practical Training (OPT) program, which allows F-1 holders to work at American companies after graduating, from 12 to 36 months.

Graduates with multiple STEM degrees (such as a bachelor’s and master’s degrees) can also chain together their OPT periods, working for up to six years in total before switching to another visa. That’s great news because each year of OPT is another chance to play the H-1B lottery, increasing your odds of winning a visa.

To use OPT, you’ll need to get a work permit (“Employment Authorization Document,” or EAD) as you near graduation. You’ll also need to file for visa extensions in order to make the most of your OPT entitlement.

If you’re on a J-1 visa

Similar to the F-1, the J-1 visa is designed for students involved in cultural exchange programs or who receive substantial funding from governments or institutions.

As a J-1 student, you won’t get OPT but 18 months of Academic Training (AT). Any internships or jobs you take during your studies will count toward your AT allotment, so it’s possible to finish your degree with less than 18 months of work authorization remaining. And while a second 18-month AT period is available for postdoctoral research, there’s no automatic extension for STEM degree holders: Once your 18 months are up, you’ll need to leave the United States.

There’s another catch: Many J-1 visas come with a home residency requirement (HRR), requiring holders to return to their home country for two years before seeking a work-based or family-sponsored U.S. visa — that or apply for an HRR waiver.

If you’re on an M-1 visa

The M-1 visa is used by students at technical and vocational schools, not academic programs. As student visas go, it’s very restrictive: You won’t be able to work off-campus and can’t work for more than six months. You also won’t be able to switch to an F-1 visa and won’t find it easy to transition to an H-1B. If you hope to stay in the United States long-term, think carefully about whether an M-1 is right for you.

No job lined up?

If you don’t have a job offer, there are other ways to stay in the United States after finishing your studies. One popular option is to enter a graduate program: Getting a master’s degree could extend your student visa by a year or two, while upgrading to a PhD program could get you several additional years. In fact, an advanced U.S. degree under your belt effectively doubles your chances of getting an H-1B in the same lottery.

If you can’t find work and don’t want to keep studying, you’ll need existing family ties to a U.S. citizen or lawful permanent resident (green card holder). If you’re the direct relative of one (for example, a spouse or child), then things are relatively easier: You have a clear path toward a family-based green card, allowing you to live and work permanently in the United States. That’s true even if you’ve become a family member through marriage: You’ll be able to obtain a marriage-based green card more quickly and easily than an H-1B or other employment-based green cards.

If you’re the spouse or child of someone on a temporary visa, such as an H-1B or O-1 visa holder, you can usually obtain a dependent’s visa. Such visas often allow you to study, but you won’t qualify for OPT after graduating. It’s also getting harder for H4 visa holders to obtain work permits, so don’t count on using a dependent’s visa to launch your career in Silicon Valley. In many cases, OPT is still a better springboard to an H-1B or green card.

If the person who claims you as a dependent applies for permanent residence, you may be able to get a green card through “derivative” benefits, meaning their green card eligibility trickles down to you.

Next step: Mark your calendar

Whatever immigration status you currently have or want to get, you’ll need to plan ahead. In some cases, you might need to start planning your next step almost as soon as you begin your studies, in order to make sure you aren’t left without a valid visa.

For graduate study : Update your existing student visa before the end of the 60-day grace period (for F-1 visas) or 30-day grace period (for J-1 visas) following the program completion date listed on your Student and Exchange Visitor Information System (SEVIS) record and I-20 or DS-2019 form.

For F-1 OPT : Apply no sooner than 90 days before and no later than 60 days after completing your studies. If your official completion date is June 1, 2020, for instance, you can apply for OPT between March 3 and July 31 of that year.

For J-1 AT : Apply shortly before your program ends. Your school will facilitate your AT application and will set its own deadline to process your paperwork before the end of your studies, but your AT must begin no later than 30 days after completing your program.

For H-1B visas : Play the annual visa lottery held in early April. You’ll need a job offer lined up well in advance from an employer who’s willing to sponsor you. You can’t begin working until your H-1B is approved, unless you have separate work authorization through OPT, AT, or some other means.

For employment-based green cards : The timeline depends on your specific green card category, but you’ll generally wait months or years .

months or years For green cards through marriage to a U.S. citizen : You’ll typically wait 10–13 months , but you’ll be able to stay in the United States while in the meantime, even if your student visa expires.

10–13 months For green cards through marriage to a permanent resident : You’ll typically wait 29–38 months , but you’ll need another valid visa, such as an unexpired F-1, for the first 11–15 months .

29–38 months 11–15 months For family-based green cards (other than for spouses and children of U.S. citizens) : You might face a lengthy wait depending on your relationship to your sponsoring relative and home country .

Whatever your plans, remember that immigration rules are constantly changing — and seldom in ways that benefit new immigrants. If you can, file your visa or green card application right away to avoid nasty surprises.

Trouble coming down the line

It’s important not only to understand your current visa but also to recognize that the U.S. immigration system is in flux — and many of the planned changes spell bad news even for immigrants with advanced degrees and vitally needed skills.

The new public charge rule, for instance, will make it harder to get a green card if you’ve used public benefits and allows the U.S. government to deny your application if they suspect you’ll fall on hard times in the future. For STEM grads with solid job offers, that might not seem like a major concern, but the new rule will apply even to those on temporary visas, including H-1Bs, who wish to extend or change their immigration status. At the least, it’s a sign of how much harder the immigration process is getting.

The Trump administration is also targeting students with a new “unlawful presence” rule that imposes tough punishments for minor violations of student visa terms. Fortunately, the rule is tied up in court, but if it goes through, it could lead to lengthy bans on future work visas if you overstay on your student visa, work in ways that aren’t authorized, or otherwise fail to play by the rules.

Such changes underscore the importance of doing your own due diligence and not simply relying on your college or employer to steer you right. Figuring out your immigration options can feel overwhelming — but as the many thousands of foreign-born STEM graduates who’ve successfully built careers in the United States can tell you, it’s well worth the effort.

Get your pressing immigration questions answered

Have a question about the complex and shifting immigration process? Boundless can help. Please send your immigration-related questions to our resident immigration expert, Anjana Prasad, at ask.anjana@boundless.com. We will consider your question for a future column on the Boundless blog.