Skip to content

Commit

Permalink
chore(docs): Add live example app to READMEs (#823)
Browse files Browse the repository at this point in the history
Adds the link to each README. Although the example is built with Next.js, it still shows the key features live, so it's useful for all SDKs.
  • Loading branch information
davidmytton authored May 24, 2024
1 parent 1df6291 commit 8b1c811
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 48 deletions.
70 changes: 41 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,47 @@ for JS.

## Quick start

- **Bun?** Use the [`@arcjet/bun`](https://www.npmjs.com/package/@arcjet/bun)
package.
- **Next.js?** Use the
[`@arcjet/next`](https://www.npmjs.com/package/@arcjet/next) package with our
[Next.js quick start guide](https://docs.arcjet.com/get-started/nextjs).
- **Node.js?** Use the
[`@arcjet/node`](https://www.npmjs.com/package/@arcjet/node) package with our
[Node.js quick start guide](https://docs.arcjet.com/get-started/nodejs).
- **SvelteKit?** Use the
[`@arcjet/sveltekit`](https://www.npmjs.com/package/@arcjet/sveltekit)
package.
- **Bun?** Use the [`@arcjet/bun`][npm-bun] package.
- **Next.js?** Use the [`@arcjet/next`][npm-next] package with our [Next.js
quick start guide][next-quick-start].
- **Node.js?** Use the [`@arcjet/node`][npm-node] package with our [Node.js
quick start guide][node-quick-start].
- **SvelteKit?** Use the [`@arcjet/sveltekit`][npm-sveltekit] package.

## Get help

[Join our Discord server](https://discord.gg/TPra6jqZDC) or [reach out for
support](https://docs.arcjet.com/support).
[Join our Discord server][discord-invite] or [reach out for support][support].

## Examples

- [Next.js rate limits](https://github.com/arcjet/arcjet-js/tree/main/examples/nextjs-14-app-dir-rl)
- [Next.js email validation](https://github.com/arcjet/arcjet-js/tree/main/examples/nextjs-14-app-dir-validate-email)
- [Protect NextAuth login routes](https://github.com/arcjet/arcjet-js/tree/main/examples/nextjs-14-nextauth-4)
- [OpenAI chatbot protection](https://github.com/arcjet/arcjet-js/tree/main/examples/nextjs-14-openai)
- [Express.js rate limits](https://github.com/arcjet/arcjet-js/tree/main/examples/nodejs-express-rl)
- ... [more examples](https://github.com/arcjet/arcjet-js/tree/main/examples)
- [Next.js rate limits](./examples/nextjs-14-app-dir-rl)
- [Next.js email validation](./examples/nextjs-14-app-dir-validate-email)
- [Bun rate limits](./examples/bun-rl)
- [Protect NextAuth login routes](./examples/nextjs-14-nextauth-4)
- [OpenAI chatbot protection](./examples/nextjs-14-openai)
- [Express.js rate limits](./examples/nodejs-express-rl)
- [SvelteKit](./examples/sveltekit)
- ... [more examples](./examples)

### Example app

Try an Arcjet protected app live at [https://example.arcjet.com][example-url]
([source code][example-source]).

## Usage

Read the docs at [docs.arcjet.com][arcjet-docs].

### Next.js rate limit example

The [Arcjet rate
limit](https://docs.arcjet.com/rate-limiting/concepts) example below
The [Arcjet rate limit][rate-limit-concepts-docs] example below
applies a token bucket rate limit rule to a route where we identify the user
based on their ID e.g. if they are logged in. The bucket is configured with a
maximum capacity of 10 tokens and refills by 5 tokens every 10 seconds. Each
request consumes 5 tokens.

See the [Arcjet Next.js rate limit
documentation](https://docs.arcjet.com/rate-limiting/quick-start/nextjs) for
details.
See the [Arcjet Next.js rate limit documentation][next-rate-limit-quick-start]
for details.

```ts
import arcjet, { tokenBucket } from "@arcjet/next";
Expand Down Expand Up @@ -102,12 +101,11 @@ export async function GET(req: Request) {

### Node.js bot protection example

The [Arcjet bot protection](https://docs.arcjet.com/bot-protection/concepts)
example below will return a 403 Forbidden response for all requests from clients
we are sure are automated.
The [Arcjet bot protection][bot-protection-concepts-docs] example below will
return a 403 Forbidden response for all requests from clients we are sure are
automated.

See the [Arcjet Node.js bot protection
documentation](https://docs.arcjet.com/bot-protection/quick-start/nodejs) for
See the [Arcjet Node.js bot protection documentation][node-bot-quick-start] for
details.

```ts
Expand Down Expand Up @@ -194,6 +192,20 @@ This repository follows the [Arcjet Security Policy][arcjet-security].
Licensed under the [Apache License, Version 2.0][apache-license].

[arcjet]: https://arcjet.com
[npm-bun]: https://www.npmjs.com/package/@arcjet/bun
[npm-next]: https://www.npmjs.com/package/@arcjet/next
[next-quick-start]: https://docs.arcjet.com/get-started/nextjs
[npm-node]: https://www.npmjs.com/package/@arcjet/node
[node-quick-start]: https://docs.arcjet.com/get-started/nodejs
[npm-sveltekit]: https://www.npmjs.com/package/@arcjet/sveltekit
[discord-invite]: https://discord.gg/TPra6jqZDC
[support]: https://docs.arcjet.com/support
[example-url]: https://example.arcjet.com
[example-source]: https://github.com/arcjet/arcjet-js-example
[rate-limit-concepts-docs]: https://docs.arcjet.com/rate-limiting/concepts
[next-rate-limit-quick-start]: https://docs.arcjet.com/rate-limiting/quick-start/nextjs
[bot-protection-concepts-docs]: https://docs.arcjet.com/bot-protection/concepts
[node-bot-quick-start]: https://docs.arcjet.com/bot-protection/quick-start/nodejs
[arcjet-docs]: https://docs.arcjet.com/
[arcjet-support]: https://docs.arcjet.com/support
[arcjet-security]: https://docs.arcjet.com/security
Expand Down
7 changes: 7 additions & 0 deletions arcjet-bun/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ against common attacks.

This is the [Arcjet][arcjet] SDK for [Bun.sh][bun-sh].

## Example app

Try an Arcjet protected app live at [https://example.arcjet.com][example-url]
([source code][example-source]).

## Installation

```shell
Expand Down Expand Up @@ -110,6 +115,8 @@ Licensed under the [Apache License, Version 2.0][apache-license].

[arcjet]: https://arcjet.com
[bun-sh]: https://bun.sh/
[example-url]: https://example.arcjet.com
[example-source]: https://github.com/arcjet/arcjet-js-example
[rate-limit-concepts-docs]: https://docs.arcjet.com/rate-limiting/concepts
[shield-concepts-docs]: https://docs.arcjet.com/shield/concepts
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
43 changes: 25 additions & 18 deletions arcjet-next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ against common attacks.

This is the [Arcjet][arcjet] SDK for the [Next.js][next-js] framework.

**Looking for our Node.js SDK?** Check out the
[`@arcjet/node`](https://www.npmjs.com/package/@arcjet/node) package.
**Looking for our Node.js SDK?** Check out the [`@arcjet/node`][alt-sdk]
package.

## Getting started

Visit [docs.arcjet.com](https://docs.arcjet.com/get-started/nextjs) to get
started.
Visit [docs.arcjet.com][next-sdk-docs] to get started.

## Example app

Try an Arcjet protected app live at [https://example.arcjet.com][example-url]
([source code][example-source]).

## Installation

Expand All @@ -38,16 +42,13 @@ npm install -S @arcjet/next

## Rate limit example

The [Arcjet rate
limit](https://docs.arcjet.com/rate-limiting/concepts) example below
applies a token bucket rate limit rule to a route where we identify the user
based on their ID e.g. if they are logged in. The bucket is configured with a
maximum capacity of 10 tokens and refills by 5 tokens every 10 seconds. Each
request consumes 5 tokens.
The [Arcjet rate limit][rate-limit-concepts-docs] example below applies a token
bucket rate limit rule to a route where we identify the user based on their ID
e.g. if they are logged in. The bucket is configured with a maximum capacity of
10 tokens and refills by 5 tokens every 10 seconds. Each request consumes 5
tokens.

See the [Arcjet rate limit
documentation](https://docs.arcjet.com/rate-limiting/quick-start/nextjs) for
details.
See the [Arcjet rate limit documentation][rate-limit-quick-start] for details.

```ts
import arcjet, { tokenBucket } from "@arcjet/next";
Expand Down Expand Up @@ -85,12 +86,11 @@ export async function GET(req: Request) {

## Shield example

[Arcjet Shield](https://docs.arcjet.com/shield/concepts) protects your
application against common attacks, including the OWASP Top 10. You can run
Shield on every request with negligible performance impact.
[Arcjet Shield][shield-concepts-docs] protects your application against common
attacks, including the OWASP Top 10. You can run Shield on every request with
negligible performance impact.

See the [Arcjet Shield
documentation](https://docs.arcjet.com/shield/quick-start/nextjs) for details.
See the [Arcjet Shield documentation][shield-quick-start] for details.

```ts
import arcjet, { shield } from "@arcjet/next";
Expand Down Expand Up @@ -129,5 +129,12 @@ Licensed under the [Apache License, Version 2.0][apache-license].

[arcjet]: https://arcjet.com
[next-js]: https://nextjs.org/
[alt-sdk]: https://www.npmjs.com/package/@arcjet/node
[next-sdk-docs]: https://docs.arcjet.com/reference/nextjs
[example-url]: https://example.arcjet.com
[example-source]: https://github.com/arcjet/arcjet-js-example
[rate-limit-concepts-docs]: https://docs.arcjet.com/rate-limiting/concepts
[rate-limit-quick-start]: https://docs.arcjet.com/rate-limiting/quick-start/nextjs
[shield-concepts-docs]: https://docs.arcjet.com/shield/concepts
[shield-quick-start]: https://docs.arcjet.com/shield/quick-start/nextjs
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
10 changes: 9 additions & 1 deletion arcjet-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ against common attacks.
This is the [Arcjet][arcjet] SDK for [Node.js][node-js].

**Looking for our Next.js framework SDK?** Check out the
[`@arcjet/next`](https://www.npmjs.com/package/@arcjet/next) package.
[`@arcjet/next`][alt-sdk] package.

## Example app

Try an Arcjet protected app live at [https://example.arcjet.com][example-url]
([source code][example-source]).

## Installation

Expand Down Expand Up @@ -122,6 +127,9 @@ Licensed under the [Apache License, Version 2.0][apache-license].

[arcjet]: https://arcjet.com
[node-js]: https://nodejs.org/
[alt-sdk]: https://www.npmjs.com/package/@arcjet/next
[example-url]: https://example.arcjet.com
[example-source]: https://github.com/arcjet/arcjet-js-example
[rate-limit-concepts-docs]: https://docs.arcjet.com/rate-limiting/concepts
[shield-concepts-docs]: https://docs.arcjet.com/shield/concepts
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
7 changes: 7 additions & 0 deletions arcjet-sveltekit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ against common attacks.

This is the [Arcjet][arcjet] SDK for [SvelteKit][sveltekit].

## Example app

Try an Arcjet protected app live at [https://example.arcjet.com][example-url]
([source code][example-source]).

## Installation

```shell
Expand Down Expand Up @@ -121,6 +126,8 @@ Licensed under the [Apache License, Version 2.0][apache-license].

[arcjet]: https://arcjet.com
[sveltekit]: https://kit.svelte.dev/
[example-url]: https://example.arcjet.com
[example-source]: https://github.com/arcjet/arcjet-js-example
[rate-limit-concepts-docs]: https://docs.arcjet.com/rate-limiting/concepts
[shield-concepts-docs]: https://docs.arcjet.com/shield/concepts
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
8 changes: 8 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This directory contains examples of how to use Arcjet.

## Example app

Try an Arcjet protected app live at [https://example.arcjet.com][example-url]
([source code][example-source]).

## Arcjet development

To develop Arcjet, use the following commands before starting the example:
Expand All @@ -11,3 +16,6 @@ export ARCJET_LOG_LEVEL=DEBUG
export ARCJET_BASE_URL=https://decide.arcjet.orb.local:4082
export NODE_TLS_REJECT_UNAUTHORIZED=0 # Allows local self-signed certs
```

[example-url]: https://example.arcjet.com
[example-source]: https://github.com/arcjet/arcjet-js-example

0 comments on commit 8b1c811

Please sign in to comment.