Use SimpleSQL from Netlify

SimpleSQL provides a REST API to create databases and manipulate them. We try to aswer the question: What if a database was as simple as a file to manage?

SimpleSQL also comes with a JS SDK to speed up development.

For instance it is possible to create a new database using the SDK calling SimpleSQL.newDatabase() or it is possible to execute SQL against the databases using SimpleSQL.command(db, "CREATE TABLE foo(a, b);")all in the frontend code without the need of a backend.

Netlify is a web service that allow to host, build, test & deploy fast loading web application.

Unfortunately they don’t provide a database and this make it difficult to build complex web application on top of their platform. (For sake of completeness, FaunaDB provide an addon for Netlify.)

SimpleSQL is a perfect match for Netlify. Allowing a simple way to manage data in the JAM stack.

You create you static web app, composed only of client-side JS, HTML and CSS. You store your data on SimpleSQL and finally you can deploy it worldwide without worrying about scalability issues.

We demonstrate this stack creating a small TODO app, the source of the application is available on github.

SimpleSQL JS SDK can import in your app from unpkg.com like so:

<script type="text/javascript" src="https://unpkg.com/@redbeardlab/[email protected]>=1.0.8"></script>

Or you can just use the file from npm @redbeardlab/simplesql .

If you decide to serve the bundle from Netlify or you include SimpleSQL SDK in your own application, you need to remember to allow the browser to make cross-origin requests (CORS) against simplesql.redbeardlab.com.

Supposing that you are serving a file called SimpleSQL.bundle.min.js from Netlify as we are doing in the example. To enable CORS you will need to create a file netlify.toml that contains the following configuration.

[[headers]]
  for = "SimpleSQL.bundle.min.js"
  [headers.values]
  Access-Control-Allow-Origin = "simplesql.redbeardlab.com"

If you are interested in using SimpleSQL the raw API is documented on Swagger.

The JS SDK is available and documented on github.

Finally you can register to have access to private databases on SimpleSQL.

Newsletter

We publish new content each week, subscribe to don't miss any article.