You can generate hydrogen from electrolysis.
Electrolysis efficiency is about 70% and you can store the hydrogen in pressurized underground caverns for a year or longer using another 0.12 kWh per kWh of hydrogen stored, which makes a total efficiency of around 0.6 kWh of hydrogen generation and storage for every kWh of electricity that you put in. (Source)
So if your electricity costs 6 ct/kWh (current LCOE of solar in many places), then hydrogen is gonna cost 10 ct/kWh to generate and store with current technology.
Currently, natural gas is around 5 ct/kWh, so solar would have to become a little bit cheaper to make it economically competitive.
Edit: to clarify, the 5 ct/kWh for natural gas is the gas alone; electricity from natural gas is more expensive than that (around 12 ct/kWh) and more expensive than solar.