How to persist data for Safari App Extensions?

I've seen a couple of answers for how to persist settings/preferences, but I want to persist larger amounts of data, data that the user will input as they're using my extension. I can't see a recommended approach to this in the Safari App Extension documentation. Before I go looking through the wider macOS development documentation, I'd like to know if there's an idiomatic way to store data for Safari App Extensions.


The data is used in the injected script. Currently, I have hardcoded data into the script so that I can use the extension. I've thought about putting this data in a JSON file and including that in the extension's resources, but I can't access the file from the script. My next thought is to pass the data to and from the extension's Swift code, and get the Swift code to store it somehow. Failing that, I would try to pass the data to and from the containing app, and get that to store it.


Any guidance would be appreciated.