KV = "TEST" assigns the string to the KV variable, instead of the KV namespace. In the old service worker syntax, removing this line would've been your solution, as bindings were global variables. In module workers (ones with export default), they are available on the env variable which is the second parameter of your fetch function in line 4, so on line 5 and 6 you should change it to env.KV.put and env.KV.get.KV in the example).env.KV 