$ npm run dev
Online.
planetscale/discussion#93 https://www.reddit.com/r/nextjs/comments/uuu4xu/does_anyone_know_how_to_use_planetscale_for_local/
Just npm run dev
and Vite will do the rest for you:
https://developers.cloudflare.com/workers/get-started/guide#2-run-your-development-server
Oh you only get planetscale (+cf workers) if you select Edge. So without Edge, you are using AWS lambda I assume. But what sql database provider do you use with AWS lambda?
A: Planetscale even when not using Edge. You probably just want to go with Edge.
https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site
The docs say a good place to start is src/lib/server/routes/_app.ts
for tRPC. So here is where you define queries, but how do you call them?
import { router, publicProcedure } from '../trpc';
import { z } from 'zod';
export const appRouter = router({
greeting: publicProcedure
.input(
z.object({
name: z.string().optional(),
})
)
.query(({ input }) => {
return `Hello, ${input.name ?? 'world'}!`;
}),
});
export type AppRouter = typeof appRouter;
It seems like you access them here src/lib/trpc/index.ts
.
import { createTRPCSvelte } from 'trpc-svelte-query';
import { ssrLink } from 'trpc-svelte-query/ssr';
import { httpBatchLink } from '@trpc/client';
import type { AppRouter } from '$lib/server/routes/_app';
import { transformer } from './transformer';
export const trpc = createTRPCSvelte<AppRouter>({
links: [
ssrLink(httpBatchLink)({
url: '/api/trpc',
}),
],
transformer,
});
Hmmmm, the structure is tricky. You have src/routes/
and also src/lib/server/routes/
.
Oh, apparently lib
contains your library code (utilities and components). server
contains your server-only library code.
So this means you can only call the greeting
route/query on the server?
How do you import the trpc
object? Just import { trpc } from '$lib/trpc/index.ts';
?