The in situ polymerized solid barrier stops sulfur transport while still allowing bidirectional Li+ transport, alleviating the shuttle effect and increasing the cycling performance.