Skip to content

Using Swup with Astro and Alpinejs #949

Answered by daun
layout-ch asked this question in Help
Discussion options

You must be logged in to vote

The simplest way of solving this would be by registering the component in the same file as the Alpine init code. Since Astro loads scripts asynchronously, it's hard to guarantee that the component is defined before the dom element is encounted by Alpine.

import Alpine from 'alpinejs'
import test from './alpine-components/test.js'
 
Alpine.data('test', test)
 
Alpine.start()

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@layout-ch
Comment options

@daun
Comment options

daun Sep 15, 2024
Maintainer

@layout-ch
Comment options

@daun
Comment options

daun Sep 15, 2024
Maintainer

@layout-ch
Comment options

Answer selected by layout-ch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants