tentei este codigo ->

<script type="text/javascript">
    document.getElementById('salvar').onclick = function(){
        let text = document.getElementById('texto').value;
        localStorage.setItem('texto', text);
    }
</script>