You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've followed the installations instructions at https://alpinejs.dev/plugins/persist to use the $persist plugin. I've added a log call in Alpine's plugin function:
and upon page load, the minified CDN distribution is logged to the console. So I assume the plugin is registering. However, Alpine.$persist calls result in Alpine.$persist is not a function errors.
Hard to tell without seeing your code. here is a codepen with a basic working example: https://codepen.io/SimoTod/pen/RwjbBeW
Are you using npm? Have you pulled an old version? Do you call Alpine.start before you add the plugin? It could be that you have imported Alpine twice as well.
In my case I was importing Alpine plugins with defer (<script defer src="https://cdn.jsdelivr.net/npm/@alpinejs/persist@3.x.x/dist/cdn.min.js"></script>).
Removing the defer attribute (so <script src="https://cdn.jsdelivr.net/npm/@alpinejs/persist@3.x.x/dist/cdn.min.js"></script>) solved the problem.
I had the script tag for the persist plugin before the script tag for Alpine and both had defer.
I got the error "Alpine.$persist is not a function".
But removing the defer from the script tag for the persist plugin made that error go away.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I've followed the installations instructions at https://alpinejs.dev/plugins/persist to use the
$persistplugin. I've added alogcall in Alpine'spluginfunction:and upon page load, the minified CDN distribution is logged to the console. So I assume the plugin is registering. However,
Alpine.$persistcalls result inAlpine.$persist is not a functionerrors.Are the docs at https://alpinejs.dev/plugins/persist#using-alpine-persist-global outdated? How can I get persist to work with
Alpine.store?All reactions