Built-in support for Content Scripts running in SPAs
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 564
- PR merge metrics
- No merged PRs in 30d
Description
Feature Request
Dealing with loading your content script correctly in SPAs is really annoying. WXT should be able to do it for you.
export default defineContentScript({
matches: ['*://*.youtube.com/watch*'],
spa: true,
main(ctx) {
console.log('YouTube content script loaded');
mountUi(ctx);
},
});
Is your feature request related to a bug?
N/A
What are the alternatives?
As the docs state, manually listening to URL changes works. But managing ctx correctly is annoying, and not shown in the docs. This would also create ctx for each URL path, so the script can shut down properly when the path changes.
Additional context
– https://discord.com/channels/1212416027611365476/1224500470278520904/1291359490121138207
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the defineContentScript API and the existing documentation for manually handling URL changes in SPAs. Determine how content-script contexts are created and stopped across path changes, then verify that the proposed spa option loads the script on matching routes and cleans up the prior context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100