SolidJS

S

SolidJS

Solid is a declarative reactive Javascript library for creating user interfaces.

Join

[error] Client-only API called on the server side. Run client-only code in onMount, or conditionally

I everyone I'm facing this error when try to deploy my website:
[error] Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.
Already try to deploy in two places, without success....
No description

Deploy on Coolify

Hi everyone Anyone deploying a solid start project on a Coolify instance?...

Details on how client code and server code is split

Is there detailed documentation on how server code and client code is split into two different bundles and how module side effects are handled? I'm having some issues with a "use server" module apparently loading server libraries into the client and I'm not sure I understand why.

When does load and preload run?

I started a solidstart project I'm toying with and I'm not understanding some of the data fetching model. ```ts export const route = { load: async () => { console.log("load!");...

Solid Start Navigation

Hi, I've got a Solid Start page, and want to navigate to a different page within a component. I basically do the following:...

"Hydrate" custom HTML

I would like to make previously-static HTML interactive. As an example for what I want, suppose the server sends HTML like ```html <ul class="todo-list"> <li>Learn SolidJS</li> <li>Create TODO-App</li>...

Confusion about `"use server"`

I have a few questions related to "use server": 1. Should all server-only files be "use server"? If not, why not? 2. I see that you can export anything other than a function from a module that is tagged with "use server", what's the reason for it? 3. Does "use server" on a module expose all functions from that module to the public (e.g. they can be called from the outside in a RPC fashion)?...

`reload`/`revalidate` + other response (e.g. `json` or `redirect`)

I'm kinda confused as to why reload and revalidate has to be part of the response from an action. How can I both reload/revalidate cache keys and also redirect or return some other response from an action?

Best practice for fetching data and the transfer data to signals that I can can them in the input fi

import { createSignal, createEffect } from "solid-js"; function UserProfile() { const [user, setUser] = createSignal({ name: "", id: "" }); const [newName, setNewName] = createSignal("");...

Redirect in createResource

Hey, I don't quite understand where to use redirect, thought it was meant to run server-side but doesnt appear to work inside a deferred createResource. What do I need to do to make this work? ```ts import { redirect } from '@solidjs/router'; import { createResource } from 'solid-js';...

Hydration Mismatch with `solid-icons`

I have this component: ``` import { JSX, Show } from "solid-js"; ...

Is `query` cached per request or globally?

Is query cached per request? The documentation doesn't seem clear about it but I'd expect so. Since I'm about to create a getViewer function it's probably best to make sure this is the case 😅

blank page on error

on occasion if there's an error that doesn't pop up in console or on my server, the route will just appear blank, with only the parent layouts rendering. this happens somewhat frequently as i'm newer to solid, and debugging it is a pain. i don't really know how to better explain it than that somewhere in the filetree my components just stop rendering but no errors show up anywhere i can send a screen recording if it'd help, but just wondering if this sounds like a familiar bug or something that others have run into...

Vercel & CORS Problem

Does anyone know how to configure CORS on Vercel with SolidStart? I keep getting...
Access to fetch at 'https://my-vercel-url.app/api/todos/get-todos' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
...

Passing Component in props

I try to generalize the following fragment: ``` <div> <div><label for="nameField">Name</label></div> <div><input id="nameField" ref={nameFieldRef} autocomplete="name" required /></div>...

Using zod to validate env vars

Is there a pattern similar to the one recommend in the React world for accessing env vars only after they have been parsed & checked by zod? Something like this: https://creatures.sh/blog/env-type-safety-and-validation/#validating-environment-variables -------------------------------------...

Pass a named function callback to an old JS library

I have a library that accepts a data-callback="someFn" attribute in one of the elements. Is there a way in SolidJS to create this function at the component level and pass it down to that attribute?

Difference between a nested route layout and just wrapping a route with a <Layout> component

Is there a practical difference between declaring a nested route layout like this: https://docs.solidjs.com/solid-start/building-your-application/routing#nested-layouts and just wrapping a route with a <Layout> component?

Is there a way to trigger a store change manually even it's still the same object?

Here is my case: ```tsx const adapter = await navigator.gpu.requestAdapter()! const device = await adapter.requestDevice()! ...

`React is not defined` error from a Solid library

I'm currently using overlayscrollbars-solid in a work project and for some reason am getting React is not defined. I've not had this error in any other part of our site but where using this library and I cannot for the life of me understand why it's showing up. The issue comes from the library itself (I added a screenshot on where specifically it's showing up) and am wondering if anyone else has encountered this / how I might fix it...
No description