Half of some 1 million gig workers in the Golden State are poised to lose income thanks to a new law expected to cause Uber and Lyft to shut down. If a court allows the law’s implementation to precede in the coming weeks, as is likely, the economic pain of many communities, including my own city of San Jose, will only deepen.

Under the new law, California Assembly Bill 5 (AB5 for short), rideshare companies like Uber and Lyft will need to treat all drivers as “employees” rather than “independent contractors,” resulting in drivers’ being scheduled for shifts in advance and being compensated for every shift whether they transport customers or not. Lyft and Uber have said they will exit their largest domestic marketbecause that rigidity is incompatible with providing services through an on-demand platform.

To combat this legislation, they have joined DoorDash, Instacart, Postmates and other on-demand companies — providers of services at the call of a customer’s smartphone — in backing a November ballot measure to reverse the law, over the fervent opposition of statewide labor organizations. Other states contemplating similar legislation, such as Illinois and New York, can expect the same battles. But this shouldn’t be a binary choice. There’s another approach in which California provides a national model for economic regulation and worker protection to keep important jobs and industries flourishing, while better compensating and safeguarding those who perform them.

The departure of Uber and Lyft from California might elicit cheers from some savvy tech cynics, brick-and-mortar defenders and mere Luddites. Yet most of us appreciate the critical value of these services in our communities. That value extends well beyond the convenience they inject into our daily routines: Theydeliver food to homebound seniors, transport patients to and from medical care,provide free rides for wildfire evacuees and support the nation’s largest bike-share networks. Most importantly for large-city mayors like me, the on-demand economy enables thousands of struggling residents to earn supplemental income to make rent amid a pandemic of unemployment.

The law poses an existential threat to the on-demand business model due to its adherence to the traditional, sclerotic dichotomy of “employees” versus “contractors.” Most on-demand networks require more flexibility than this traditional set-up to enable minute-to-minute adjustments to service levels to meet customer needs. A ridesharing network depends upon having lots of part-time drivers available for brief, peak periods of ride requests — such as during rush hour, when bars close on a Saturday night or the arrival time for several international flights at the airport.

Consumer demand will suffice only to pay a very small number of drivers for eight-hour shifts. That’s fine for many gig workers, who have other jobs, parenting responsibilities or college classes to attend; 82 percent of Lyft drivers work fewer than 20 hours per week. But since customer demand in any one geographic market is high enough to support drivers working predictable, eight-hour shifts in only a few large cities, suburban and rural customers would return to the days of waiting upwards of an hour for a taxi to the airport. Moreover, hundreds of thousands drivers who are willing — and even prefer — to work only a few hours a week will have to search for other work.

Of course, the status quo is also not acceptable. We need to ensure fair compensation for gig workers if our global economy dictates that on-demand services and flexible work arrangements are here to stay. Too many independent workers — whether drivers, artists or writers — struggle with low wages, a lack of basic worker protections and no retirement security.

Rather than trying to fit the square peg of “gig workers” into the round hole of “employees,” we have an opportunity to imagine a new approach to independent work. California can provide a model for the rest of the nation by creating portable benefits: Every company would pay into an individualized fund an hour’s worth of the cost of benefits for every hour a contractor works.

That portable fund would stay with a gig worker throughout his or her life, like Social Security or a 401k, and workers could choose to spend it on health insurance, retirement or any other benefit they choose. Hardly a new idea — it has been championed by progressives leading California’s Fair Shake Commission, advanced by the Aspen Institute and proposed in federal legislation authored by Sen. Mark Warner (D., Virg.) — portable benefits are essential for protecting our 21st century workforce.

Further forward-thinking legislation should mandate that rideshare and delivery companies provide other basic safety nets as well: minimum hourly pay, collision insurance, workers’ compensation and reimbursement of other driver costs. Since many gig workers have transitioned out of stable careers, companies should also be required to contribute a percentage of their revenues to job retraining programs.

In addition, the state should mandate driver safety standards, discrimination protections and collective bargaining rights to ensure uniform application of these independent worker protections industrywide, so that companies don’t gain cost advantages over competitors at the expense of workers.

Leading companies could agree to all of this and more. How can we be so sure? The CEOs of Uber and Lyft have said so publicly, and have sought to negotiate with unions and state lawmakers for just these kinds of measures. Diverse state organizations, ranging from the California NAACP, the Los Angeles Urban League, the California Black Chamber of Commerce and National Organization for Women, also support this innovative approach.

How can we get there? State leaders need to use this time-out — a stay of the law handed down by the court on Thursday — to bring industry and labor back to the negotiating table to produce a deal. We also need the political will in Sacramento to get it passed in the legislature and onto the governor’s desk — quickly.

California can choose to implement solutions that lead the innovation economy, or to be led by others. The livelihoods of nearly one million residents depend on California choosing to lead.

*by Sam Liccardo, mayor of San Jose via NBC News*