Battery doesn't make sense for a second-scale energy storage. Due to the nature batteries deliver and accept currents (fairly low (dis)charge rates as a proportion to their capacity), you would need to design it to supply at least 10 minutes to half an hour, to satisfy the current spec; if you only need a second, the rest is excess capacity.
Supercapacitors are the choice for a few seconds, to about half a minute tops. In this range, they will be cheaper (but not much smaller) than buying a battery pack which is 100 times bigger capacity than needed.
Traditional aluminium electrolytics may be the most economical below about one second, instead of supercaps.
What you need is a grid-tie inverter. You are not going to be able to do it yourself, or come up with any really good alternative. Saving a bit by getting a traditional non-grid-tie inverter, then spending extra on a complex and potentially dangerous contactor system, then completely wasting all your produced power (say 1000W) when the sun happens to be shining while you need 1001W, makes no sense.