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โข3mo ago
which solid start?
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โข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
insteaddeep-jadeOPโข3mo ago
thanks! so now i have such package.json:
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โข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-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โข3mo ago
that's what I wrote here ๐
yes
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โข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โข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โข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โข3mo ago
but i would really start off with the alpha branch if you just start out now
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-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โข3mo ago

adverse-sapphireโข3mo ago
from the guide
install with
@alpha
deep-jadeOPโข3mo ago
okay thank you!