Back to articles
SolidStart Has a Free API That Makes Solid.js a Full-Stack Framework

SolidStart Has a Free API That Makes Solid.js a Full-Stack Framework

via Dev.to JavaScriptAlex Spinov

SolidStart is the meta-framework for Solid.js — file-based routing, server functions, and streaming SSR with Solid's fine-grained reactivity. File-Based Routing src/routes/ index.tsx → / about.tsx → /about products/ index.tsx → /products [id].tsx → /products/:id api/ products.ts → /api/products Server Functions: RPC Without an API " use server " ; import { db } from " ./db " ; export async function getProducts ( category ?: string ) { return db . product . findMany ({ where : category ? { category } : {}, orderBy : { createdAt : " desc " }, take : 20 , }); } export async function createProduct ( data : { title : string ; price : number ; url : string }) { return db . product . create ({ data }); } // In your component — calls server function directly! import { createResource } from " solid-js " ; import { getProducts } from " ./server " ; function ProductList () { const [ products ] = createResource (() => getProducts ( " electronics " )); return ( < For each = { products () } > { ( pr

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
2 views

Related Articles