Live data from Hacker News

SvelteKit 1.0

svelte.dev

91–100 of 296 posts

Re: SvelteKit 1.0

#91
post #27

This is how I move fast and break nothing. By having fullstack type-safety from database all the way to the frontend with auto-completion. My current stack: + SvelteKit (could be Next, Nuxt, Solid or any other TypeScript framework) + tRPC (typed calls between frontend and backend, https://trpc.io ) + trpc-sveltekit (glues SvelteKit and tRPC, https://github.com/icflorescu/trpc-sveltekit ) + Prisma (ORM, https://www.pr…

Same, but with ASP.NET (which produces an OpenAPI specification) + Entity Framework on the server, React + TypeScript on the client (which consume that specification through openapi-generator).

https://github.com/OpenAPITools/openapi-generator

I chuckle every time I read claims about Go (or whatever) being amazingly productive. I don't think it's possible to beat this stack with regards to both productivity and ease of long-term support, at least without going to very niche technologies where you'll have other problems.

Database schema is generated from models described in C# (or reverse-engineered from an existing schema). You don't have to compromise your schema to satisfy the ORM (another claim I often read on HN), as it's very adaptable to your needs.

Migrations are generated automatically — change your models, ask it to generate migration code in C# + a SQL migration script, review the generated SQL, and apply.

The vast majority of database queries (pretty much everything besides reports) is written in type-safe LINQ, which makes it easy to refactor code, and also construct & combine queries at runtime. Unlike that specification abomination JPA expects you to use, LINQ queries look something like this:

  var latestOrders = _db.Orders
    .Where(ord => ord.CreatedAt >= DateTime.Today)
    .Where(ord => !ord.Deleted)
    .OrderByDescending(ord => ord.CreatedAt)
    .Take(25)
    .Select(ord => new {
      OrderId = ord.Id,
      Customer = ord.Customer.Name,
      CreatedAt = ord.CreatedAt,
      Products = ord.Products.Select(prod => new {
        ProductId = prod.Id,
        Title = prod.Title,
      })
    })
    .ToList();
If you change your schema and forget to update one of the queries accordingly (although using an IDE makes this pretty much impossible), your code won't even compile.

Re: SvelteKit 1.0

#92
post #69

"This app requires modern web platform features. Please use a browser other than Safari." Looks cool but not production ready.

I always wonder why Hacker News is such a magnet for comments trashing product announcements while also knowing almost nothing about the product being announced.

In the long run the approach Svelte takes seems very promising so I've kept an eye on it for a while now. I took umbrage at the snooty messaging towards a browser in a tool pitched as a way to "build production-grade websites".

Re: SvelteKit 1.0

#93

All the praise for SvelteKit in this thread peaked my interest. But where would I start? I'm currently looking around to find a modern "toolkit" to write a new webbased frontend for our traditional desktop app. It's goin to be more or less CRUD with lots of tables/grids. Currently I favour vue.js with Quasar because of all the tooling and ressources it offers. It looks like it's easy to start with a traditional "navi…

You can start here: https://learn.svelte.dev/tutorial/welcome-to-svelte

> Yikes! We couldn't start the app. Please ensure third party cookies are enabled for this site.

Yikes! No thanks.

Re: SvelteKit 1.0

#94
post #66

There is a plethora of javascript frameworks: React, Vue, Svelte, Remix, etc. If I know nothing about front-end development, and would like to learn one that is: - Intuitive - Suitable for small projects as well as large projects. - That is here to stay, i.e. either adopted by many companies, or its adoption curve is going up. Which one should I pick? Would Svelte be a good choice?

If it's for your career: React + (Next or Remix). Maybe Angular or Vue if the specific company you want uses it

If it's for yourself: Svelte. Amazing community, very likely to be here in 5 years, but I don't think it's been proven to work at large scales yet.

If you want to twist everything upside down and see the full potential of what front-end dev work could be: Qwik or Elm (imho)

Re: SvelteKit 1.0

#95

There is so much "let me just see if this works..." tap tapppy tap .... "no... NO WAY... OMG IT WORKED!" with Svelte. Very little surface area. It embraces your knowledge of plain ole CSS/JS/HTML and empowers you with reactivity and a means of if being able to add motion to your ui. Newbs and Pros alike can build fast with it. That speed + reactivity allows your software to better keep up with your converstaions that…

Except it forces you to use node js, or do I read it wrong? Can we get a streamlined js framework that is just about the frontend and let’s you use whatever backend language you want? I know there is react, vue and angular but they seem so bloated

Re: SvelteKit 1.0

#96
post #27

This is how I move fast and break nothing. By having fullstack type-safety from database all the way to the frontend with auto-completion. My current stack: + SvelteKit (could be Next, Nuxt, Solid or any other TypeScript framework) + tRPC (typed calls between frontend and backend, https://trpc.io ) + trpc-sveltekit (glues SvelteKit and tRPC, https://github.com/icflorescu/trpc-sveltekit ) + Prisma (ORM, https://www.pr…

I use the same, but with Hasura and Next.js with GraphQL

+ Next.js

+ GraphQL Zeus / GraphQL Code Generator (typed calls between frontend/backend)

+ Hasura (generates GraphQL API for database)

Re: SvelteKit 1.0

#97
post #72
post #67

Earlier quoted context omitted.

A lot has changed in the past years of Prisma, it's a really great tool, to be honest, "raw sql" escape hatches to do anything raw when you need it, if you haven't tried it in years, I'd recommend you to try again since if you tried it years ago, it was a very different maturity level.

Do they (Prisma) still rely on a Rust sidecar? This caused multiple issues with container deployment and the CI/CD pipeline of my employer.

I believe the sidecar is optional now, and I think even the one that exists comes in the form of their paid service called Prisma Proxy. It doesn’t seem necessary for most use cases.

Re: SvelteKit 1.0

#98
post #26

I'm just completing a job using svelte/kit, tailwind, postgres, typescript. Actually, I was new to the entire stack, but it went smooth as butter. (Though I have plenty of experience with JS, HTML, CSS, other databases, etc.) IMO, svelte and sveltekit are well designed and have a great dev experience. LOL, as I was writing this he was apologizing on the stream for the breaking changes. That was a bit of a pain, but n…

> My only real gripe is using folders to organize both layout hierarchy and route hierarchy is going to turn out to be a mistake.

+1 to this. I think Next.js made this mistake too and is now backtracking

Re: SvelteKit 1.0

#99
post #54

Earlier quoted context omitted.

How are you liking Prisma compared to a pure SQL approach?

When I used prisma a few years ago I was not impressed and it couldn't do a lot of what I needed so I had to dump into raw sql queries anyway. It was easier for me to use knex and get the types mostly right.

You should take a look at ts-sql-query [1] - it is not as popular as the older alternatives that have been around for a while, but it is a very feature rich query builder that takes type safety very seriously and supports most mainstream databases.

[1] https://ts-sql-query.readthedocs.io

Re: SvelteKit 1.0

#100

There is so much "let me just see if this works..." tap tapppy tap .... "no... NO WAY... OMG IT WORKED!" with Svelte. Very little surface area. It embraces your knowledge of plain ole CSS/JS/HTML and empowers you with reactivity and a means of if being able to add motion to your ui. Newbs and Pros alike can build fast with it. That speed + reactivity allows your software to better keep up with your converstaions that…

I had the opposite feeling a month or so ago, especially with stores- there's so much "magic" that I kept running into confusing walls. If I `export let` a variable to be reactive over here, why isn't it reactive over there?

You seem to be conflating a few different concepts. Store are absolutely reactive across all components and pages. They are prefaced with $, and there are a bunch of native stores that you can use such as $page.

You can even create variables reactive to one another by declaring a variable like so:

$: y = x * 2

Using the export let x = default; option is for passing data from the parent component/page to a child. If you want variable changes in the child to be reflected in the parent, you can use a store ($ notation), or you can use bind like so:

In my opinion, all of this is much much easier than in competing frameworks.

Post reply on HN