T
TanStackโ€ข6mo ago
manual-pink

api routes in solid start

Hi, is it possible to create an api route in solid start with tanstack router? when i add api folder with firebase-handler.ts i get populated with import { createFileRoute } from '@tanstack/solid-router' export const Route = createFileRoute('/api/firebase-handler')({ component: RouteComponent, }) function RouteComponent() { return <div>Hello "/api/firebase-handler"!</div> } and i get 503 error, there is nothing in the docs about api routes, thanks.
17 Replies
quickest-silver
quickest-silverโ€ข6mo ago
which solid start?
manual-pink
manual-pinkOPโ€ข6mo ago
"@solidjs/start": "^1.1.2", "@tanstack/router-plugin": "^1.112.0", "@tanstack/solid-router": "^1.114.1", "@tanstack/solid-router-devtools": "^1.114.1", thanks!
quickest-silver
quickest-silverโ€ข6mo ago
ah ok, no idea about that combo unfortunately most likely you should not create the api route in router if you want solid/start to serve it i would recommend @tanstack/solid-start instead
manual-pink
manual-pinkOPโ€ข6mo ago
thanks! so now i have such package.json:
"@solidjs/start": "^1.1.2",
"@tanstack/router-plugin": "^1.112.0",
"@tanstack/solid-router": "^1.114.1",
"@tanstack/solid-router-devtools": "^1.114.1",
"@solidjs/start": "^1.1.2",
"@tanstack/router-plugin": "^1.112.0",
"@tanstack/solid-router": "^1.114.1",
"@tanstack/solid-router-devtools": "^1.114.1",
and still getting 503 Server Unavailable TypeError: Cannot read properties of undefined (reading 'update') when i create api folder in routes folder i get it populated likle it was a route and when i replace this code with import type { APIEvent } from "@solidjs/start/server"; export async function GET(event: APIEvent) { return new Response("OK", { status: 200 }); } I assume that this is from solid router b ut is there no way to create API Routes in tanstack router for solid js?
quickest-silver
quickest-silverโ€ข6mo ago
why are you mixing server side stuff with Tanstack router? if you are not using @tanstack/solid-start, Tanstack router will only be client side
manual-pink
manual-pinkOPโ€ข6mo ago
ah ok i thought tanstack start is only for React, would you recommend @tanstack/solid-start over regular solid start with solid router?
quickest-silver
quickest-silverโ€ข6mo ago
that's what I wrote here ๐Ÿ˜„ yes
manual-pink
manual-pinkOPโ€ข6mo ago
sorry my bad ๐Ÿ™‚ and thank you! so api routes are server functions? i wrote tanstack router docs yesterday and did not find about api routes
quickest-silver
quickest-silverโ€ข6mo ago
no server functions and API routes (btw they have been renamed to server routes on the alpha version) are different you looked at the wrong docs ๐Ÿ˜„ this is a Start feature, not a Router feature
quickest-silver
quickest-silverโ€ข6mo ago
Server Functions | TanStack Start Solid Docs
What are Server Functions? Server functions allow you to specify logic that can be invoked almost anywhere (even the client), but run only on the server. In fact, they are not so different from an API...
quickest-silver
quickest-silverโ€ข6mo ago
API Routes | TanStack Start Solid Docs
API Routes are a powerful feature of TanStack Start that allow you to create server-side endpoints in your application without the need for a separate server. API Routes are useful for handling form s...
quickest-silver
quickest-silverโ€ข6mo ago
but i would really start off with the alpha branch if you just start out now
quickest-silver
quickest-silverโ€ข6mo ago
GitHub
Start BETA - Tracking ยท TanStack router ยท Discussion #2863
Tracking any important changes for TanStack Start during the BETA period. If you are coming from the ALPHA of TanStack Start, you can see all the breaking changes that were made here - #2403
manual-pink
manual-pinkOPโ€ข6mo ago
right ;p thank you! ๐Ÿ™‚ that super helped me ๐Ÿ™‚ @Manuel Schiller how can i install alpha version? I think i installed beta because i had to rename src to app
quickest-silver
quickest-silverโ€ข6mo ago
No description
quickest-silver
quickest-silverโ€ข6mo ago
from the guide install with @alpha
manual-pink
manual-pinkOPโ€ข6mo ago
okay thank you!

Did you find this page helpful?