Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 3 min read Opinion easyNovice

Is “SQL from the frontend” viable?

Letting the frontend query the database directly, via tools like PostgREST or Firebase, can sharply speed up development by removing backend abstraction layers and frontend/backend team dependencies, which makes it attractive for prototypes and many apps. It does not have to replace the backend, which still holds secrets and sensitive logic. Exposing a database safely would require query-shape and parameter allow-listing with tooling to maintain the lists, per-IP rate limiting, and database-level authorization such as Postgres Row-Level Security. The verdict is that the approach is not production-ready yet, and Neon is exploring it through its RLS work, now part of the Neon Data API.

Related posts

  • Introducing Neon RLS: Simplifying Row-Level Security For Postgres

    Neon mediumAdept

    Neon RLS lets Postgres row-level security policies authenticate requests with JWTs from any auth provider that exposes a JWKS URL. The Neon Proxy verifies the token and exposes its claims through auth.user_id() and auth.session() from the open-source pg_session_jwt extension, for use in RLS policies and WHERE clauses. A Drizzle ORM integration adds pgPolicy and crudPolicy helpers so policies are declared alongside the schema. Neon recommends RLS for core authorization rules such as multi-tenant isolation, keeping intricate access logic in backend code, and says backend-less client apps are only suitable for simple projects.

  • Oops-Proof Your Vibe Code With Neon: Because Mistakes Happen

    Neon mediumAdept

    Neon's built-in safety features act as guardrails for databases behind AI-generated ("vibe coded") apps: point-in-time restore, snapshots, protected branches, IP allowlisting, mandatory SSL/TLS (sslmode=require) and password resets, each with brief console steps. The most concrete guidance covers SQL injection, contrasting string-interpolated queries with parameterized `$1` placeholders in pg. It also shows that Neon's serverless driver tagged-template `sql` function treats interpolated values as data. The practical advice is to check AI-generated db code for unparameterized queries and take a snapshot before risky schema changes.

  • The Dangers of Testing in SQLite as a Postgres User

    Neon mediumAdept

    Testing against SQLite when production runs Postgres gives false confidence. SQLite's type affinity accepts a float in an INTEGER column that Postgres rejects. It also lacks native JSONB operators, arrays and advanced window functions. Its database-level, single-writer locking and in-process, low-I/O design hide Postgres concurrency behavior and performance characteristics. The recommended alternative is ephemeral Neon branches per test, which give real Postgres semantics with throwaway isolation.

  • Building with Stripe Data Pipeline and the Neon backend

    Neon mediumAdept

    Stripe Data Pipeline's real-time sync streams Stripe objects into Postgres tables within seconds, which lets apps drop webhooks entirely: they write to Stripe's API and read charges, prices and promotion codes from synced stripe.* tables. Two example apps compute credit balances as a SQL view (purchased minus spent), so refunds, disputes and duplicate deliveries are handled without handler code. Double spending is prevented by a per-user advisory lock plus a conditional UPDATE that claims a job only if the view shows enough balance. Neon point-in-time branches copy Stripe data, app data, object storage and disabled triggers, so billing bugs can be reproduced and fixed locally without touching production.

  • Recreating S3 in Postgres using PostgREST

    Neon mediumAdept

    A simple S3-like file server can be built inside Postgres by storing binary data in a BYTEA table and exposing it through PostgREST's functions-as-RPC via the Neon Data API. A custom "*/*" domain lets a PL/pgSQL function return arbitrary media types and set Content-Type, Content-Disposition and Cache-Control headers, and generated columns compute size, MIME type and SHA-256 hash. Row-level security policies on anonymous and authenticated roles, with JWT-based user IDs, restrict access to public or owned blobs. Tables grant SELECT to anonymous users by default, so RLS setup is essential, and the pattern is meant as a teaching vehicle rather than a real S3 replacement.

The quest for software engineering knowledge.

Look:
Layout: