Open sullyj3 opened 6 months ago
The best solution for this would be to add typing for the chrome api with this package. I'm looking into ways to add it for intellisense to also pick up and use it correctly
I am also using chrome API (chrome.storage.local). Because this API can only be accessed from the client, I set prerender = true
and ssr = false
in +layout.ts
. While developing, I use localStorage to mock the behavior of chrome.storage.local
, and it works fine.
But when I build the app and unpack it, then open the extension, it shows 404 not found. The console error says Error: Not found: /index.html
, even though the index.html
file is present on the build folder. I suspect the problem comes from the script tag inside index.html
.
If i remove ssr = false
, the extension works fine, but I have to make a lot of adjustment (like using onMount
and browser
variable) to make sure chrome.storage.local
only called in the browser, which is a lot of hassle and not very clean, because I have to do this in multiple files.
My question is, does this adapter doesn't work for ssr = false
? or maybe there is something wrong my implementation? Thankyou in advance!
Hi! I'm trying to write an extension which accesses the chrome bookmarks API, but I'm having some trouble understanding how to use it correctly in the context of sveltekit. I started from this template repository.
To start with I wanted to just display a
BookmarkTreeNode
, so I editedsrc/routes/+page.svelte
with the following:(here's the docs for chrome.bookmarks.getTree)
This works as expected, displaying this JSON:
The problem comes in when I try to actually access the node. When I edit the html with the following instead:
I get a compile error:
referring to the
bookmarks[0]
in the html. I'm a bit hazy on how sveltekit works, but my intuition says the error is to do with SSR and the bookmarks not being available when the page is being prerendered? Is that right?How do I do this correctly?