T
TanStackโ€ข3mo ago
deep-jade

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
adverse-sapphire
adverse-sapphireโ€ข3mo ago
which solid start?
deep-jade
deep-jadeOPโ€ข3mo 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!
adverse-sapphire
adverse-sapphireโ€ข3mo 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
deep-jade
deep-jadeOPโ€ข3mo 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?
adverse-sapphire
adverse-sapphireโ€ข3mo 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
deep-jade
deep-jadeOPโ€ข3mo ago
ah ok i thought tanstack start is only for React, would you recommend @tanstack/solid-start over regular solid start with solid router?
adverse-sapphire
adverse-sapphireโ€ข3mo ago
that's what I wrote here ๐Ÿ˜„ yes
deep-jade
deep-jadeOPโ€ข3mo 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
adverse-sapphire
adverse-sapphireโ€ข3mo 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
adverse-sapphire
adverse-sapphireโ€ข3mo 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...
adverse-sapphire
adverse-sapphireโ€ข3mo 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...
adverse-sapphire
adverse-sapphireโ€ข3mo ago
but i would really start off with the alpha branch if you just start out now
adverse-sapphire
adverse-sapphireโ€ข3mo 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
deep-jade
deep-jadeOPโ€ข3mo 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
adverse-sapphire
adverse-sapphireโ€ข3mo ago
No description
adverse-sapphire
adverse-sapphireโ€ข3mo ago
from the guide install with @alpha
deep-jade
deep-jadeOPโ€ข3mo ago
okay thank you!

Did you find this page helpful?