Skip to content

Commit

Permalink
Add SDK page to docs (#486)
Browse files Browse the repository at this point in the history
* Start SDK page

* Reorganise links

* Tweaks

* Fix link

* Add packages and examples

* Add link to reference

* Link authors

* Improve TS

* Fix path to consts

* Add PyPI package

* Fix spacing

* Add links to SDKs page

* Cleanup
  • Loading branch information
bencroker authored Jan 19, 2025
1 parent 4d6ca33 commit 8b43f29
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
1 change: 1 addition & 0 deletions site/routes_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func setupReferenceRoutes(ctx context.Context, router chi.Router) error {
{ID: "action_plugins"},
{ID: "sse_events"},
{ID: "javascript_api"},
{ID: "sdks"},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion site/static/md/guide/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ We've just scratched the surface of frontend reactivity. Now let's take a look a

Datastar uses [Server-Sent Events](https://en.wikipedia.org/wiki/Server-sent_events) (SSE) to stream zero or more events from the web server to the browser. There's no special backend plumbing required to use SSE, just some syntax. Fortunately, SSE is straightforward and [provides us with some advantages](/essays/event_streams_all_the_way_down).

First, set up your backend in the language of your choice. Using one of the helper SDKs (currently available for [Go](https://github.com/starfederation/datastar/tree/main/sdk/go), [PHP](https://github.com/starfederation/datastar/tree/main/sdk/php), [dotnet](https://github.com/starfederation/datastar/tree/main/sdk/dotnet) and [Java](https://github.com/starfederation/datastar/tree/main/sdk/java)) will help you get up and running faster. We're going to use the SDKs in the examples below, which set the appropriate headers and format the events for us, but this is optional.
First, set up your backend in the language of your choice. Using one of the backend [SDKs](/reference/sdks) will help you get up and running faster. We're going to use the SDKs in the examples below, which set the appropriate headers and format the events for us, but this is optional.

The following code would exist in a controller action endpoint in your backend.

Expand Down
2 changes: 1 addition & 1 deletion site/static/md/guide/going_deeper.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ event: datastar-execute-script
data: script console.log('Success!')
```

Using one of the helper SDKs (currently available for [Go](https://github.com/starfederation/datastar/tree/main/sdk/go), [PHP](https://github.com/starfederation/datastar/tree/main/sdk/php), [dotnet](https://github.com/starfederation/datastar/tree/main/sdk/dotnet) and [Java](https://github.com/starfederation/datastar/tree/main/sdk/java)) will help you get up and running faster.
Using one of the backend [SDKs](/reference/sdks) will help you get up and running faster.

Here is all of the backend code required to produce the events above in each of the SDKs.

Expand Down
64 changes: 64 additions & 0 deletions site/static/md/reference/sdks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# SDKs

Datastar provides backend SDKs that simplify the process of generating [SSE events](/reference/sse_events) specific to Datastar.

## Go

[Go SDK](https://github.com/starfederation/datastar/tree/develop/sdk/go)

_Author: [Delaney Gillilan](https://github.com/delaneyj)_

Examples:

- [1 App 5 Stacks ported to Go+Templ+Datastar](https://github.com/delaneyj/1a5s-datastar)

## PHP

[PHP SDK](https://github.com/starfederation/datastar-php)

- [Laravel package](https://github.com/putyourlightson/laravel-datastar)

- [Craft CMS plugin](https://putyourlightson.com/plugins/datastar)

_Author: [Ben Croker](https://github.com/bencroker) ([PutYourLightsOn](https://putyourlightson.com/))_

Examples:

- [Craft Datastar Pokemon demo](https://github.com/khalwat/craft-datastar-pokemon-demo)

## Python

[Python SDK](https://github.com/starfederation/datastar/tree/develop/sdk/python) and [PyPI package](https://pypi.org/project/datastar-py/), including support for Sanic, Django, Quart and FastAPI.

_Author: [Felix Ingram](https://github.com/lllama)_

Examples:

- [Python examples](https://github.com/starfederation/datastar/tree/develop/examples/python)

## TypeScript

[TypeScript SDK](https://github.com/starfederation/datastar/tree/develop/sdk/typescript), including support for NodeJS and Web standard runtimes (Deno, Bun, etc.).

_Author: [Patrick Marchand](https://github.com/Superpat)_

Examples:

- [NodeJS example](htttps://github.com/starfederation/datastar/tree/develop/sdk/typescript/examples/node.ts)
- [Deno example](htttps://github.com/starfederation/datastar/tree/develop/sdk/typescript/examples/deno.ts)

## dotnet

[dotnet SDK](https://github.com/starfederation/datastar/tree/develop/sdk/dotnet), including support for C#.

_Author: [Greg H](https://github.com/SpiralOSS)_

Examples:

- [dotnet examples](https://github.com/starfederation/datastar/tree/develop/examples/dotnet)

## Java

[Java SDK](https://github.com/starfederation/datastar/blob/develop/sdk/java)

_Author: [Peter Humulock](https://github.com/rphumulock)_
2 changes: 1 addition & 1 deletion site/static/md/reference/sse_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Responses to [backend plugin actions](/reference/action_plugins#backend-plugins)
<div class="alert alert-info">
<iconify-icon icon="simple-icons:rocket"></iconify-icon>
<div>
The helper SDKs (currently available for <a href="https://github.com/starfederation/datastar/tree/main/sdk/go">Go</a>, <a href="https://github.com/starfederation/datastar/tree/main/sdk/php">PHP</a>, <a href="https://github.com/starfederation/datastar/tree/main/sdk/dotnet">dotnet</a>, <a href="https://github.com/starfederation/datastar/tree/main/sdk/java">Java</a>) can handle the formatting of SSE events for you.
The backend <a href="/reference/sdks">SDKs</a> can handle the formatting of SSE events for you.
</div>
</div>

Expand Down

0 comments on commit 8b43f29

Please sign in to comment.