Softwr

Web Development · head to head

Preact vs Swift

Preact logo

Preact

Web Development

3kB alternative to React with the same modern API

From
Free
Free plan
Yes
Swift logo

Swift

Mobile Development

Open source programming language from Apple for apps, servers and embedded systems

From
Free
Free plan
Yes

The short version

  • Both are free.
  • Only Preact lists 3kB runtime; only Swift lists native compiled code.
  • Where Preact falls short: compatibility through preact/compat is good but not total, and some React libraries break in ways that are hard to diagnose.
  • Where Swift falls short: strongest tooling is on Apple platforms, with Xcode for iOS and macOS apps.

How do Preact and Swift differ?

Preact and Swift differ on pricing model, platforms and category (Web Development against Mobile Development). Only the attributes on which Preact and Swift actually diverge.

Attributes where Preact and Swift differ
AttributePreactSwift
Pricing modelOpen source, no licence feeOpen-source
PlatformsWebmacOS, Linux, Windows, iOS
CategoryWeb DevelopmentMobile Development

Identical on both: starting price (Free), free tier (Yes).

Which features does each one have?

They share no listed features; 4 appear only for Preact and 8 only for Swift. Drawn from each product's published feature list. An absence here means we hold no record of it - not that the product lacks it.

Only in Preact

  • 3kB runtime
  • preact/compat
  • Same modern API
  • Fast rendering

Only in Swift

  • Native compiled code
  • Type inference and optionals
  • Memory and data race safety checks
  • async and await with actors
  • C and C++ interoperability
  • Package ecosystem
  • Linux, macOS and Windows toolchains
  • Embedded and server targets

What is each one used for?

Preact is most often brought in for embedded widgets that load inside someone else’s page and must stay small; Swift for iOS and macOS apps. The jobs each tool is most often brought in to do.

Preact

  • Embedded widgets that load inside someone else’s page and must stay smallnot Swift
  • Marketing and content sites where JavaScript payload affects Core Web Vitalsnot Swift
  • Applications targeting low-bandwidth or low-powered devicesnot Swift

Swift

  • iOS and macOS appsnot Preact
  • Server-side servicesnot Preact
  • Command-line toolsnot Preact
  • Embedded firmwarenot Preact

Where do Preact and Swift fall short?

Preact's most cited limit: behavioural differences from React exist in edge cases, particularly around event handling. Swift's: strongest tooling is on Apple platforms, with Xcode for iOS and macOS apps. Documented limitations, not opinions. Every one is a constraint you would hit in normal use.

Preact

  • Compatibility through preact/compat is good but not total, and some React libraries break in ways that are hard to diagnose
  • Behavioural differences from React exist in edge cases, particularly around event handling
  • A much smaller community, so unusual problems have fewer existing answers than React

Swift

  • Strongest tooling is on Apple platforms, with Xcode for iOS and macOS apps
  • It is a language, so UI, server and database libraries are separate choices
  • Versions 1.0 to 2.1 were proprietary and later versions are Apache 2.0
  • Cross-platform mobile UI needs other frameworks such as Flutter or React Native

How much do Preact and Swift cost?

Preact is free to use; Swift is free to use. Plan by plan below, from each vendor's own pricing page.

Preact

Free
  • PreactFree
    • Full library
    • Commercial use permitted
    • No usage limits

Swift

Free

No published plan breakdown. See the Swift review.

Which should you pick?

Choose Preact if

  • You need 3kb runtime.
  • You want to start without paying.
  • You also want preact/compat.

Choose Swift if

  • You need native compiled code.
  • You want to start without paying.
  • You work on macOS, Linux, Windows, iOS.
  • You also want type inference and optionals.

Questions people ask

Is Preact or Swift better?
It depends on the job. Preact fits embedded widgets that load inside someone else’s page and must stay small; Swift fits iOS and macOS apps. Preact starts at Free and Swift at Free.
Which is cheaper, Preact or Swift?
Preact starts at Free and Swift at Free.
Does Preact or Swift run on more platforms?
Preact runs on Web. Swift runs on macOS, Linux, Windows, iOS.
Can I use Preact for free?
Both have a free tier, so you can try either at no cost before committing.
What is Preact best used for?
Preact is most often used for embedded widgets that load inside someone else’s page and must stay small, marketing and content sites where javascript payload affects core web vitals, applications targeting low-bandwidth or low-powered devices. Of those, embedded widgets that load inside someone else’s page and must stay small and marketing and content sites where javascript payload affects core web vitals are not what Swift is typically brought in for.
What can Preact do that Swift cannot?
Preact covers 3kB runtime, preact/compat, Same modern API, Fast rendering. Swift covers Native compiled code, Type inference and optionals, Memory and data race safety checks, async and await with actors.

Answered from the vendors’ own pages

Preact: Is Preact free?

Yes, open source under the MIT licence.

Swift: Is Swift open source?

Yes. Wikipedia says it has been released under Apache 2.0 since version 2.2 in December 2015, and the Swift site links to the SwiftLang GitHub organisation.

Source
Preact: Can I use React libraries with Preact?

Most, through the preact/compat layer. Compatibility is good but not complete, so libraries relying on React internals can break.

Swift: Which platforms does Swift run on?

The Swift site lists tools for Linux, macOS and Windows, and Wikipedia also lists Apple operating systems, WebAssembly and Android. The infobox also lists FreeBSD and z/OS.

Source
Preact: Why choose Preact over React?

Bundle size, almost always. If payload is not a binding constraint, React’s ecosystem is usually the better trade.

Swift: When was Swift released?

Apple showed it at WWDC on 2 June 2014, and Swift 1.0 arrived in September 2014, according to Wikipedia. Swift 5 in 2019 brought a stable binary interface.

Source
Share

Related pages

Other head to heads