Skip to content
/ example-nextjs-fly Public template
generated from arcjet/example-nextjs

An example Next.js application protected by Arcjet and deployed on Fly.io

License

Notifications You must be signed in to change notification settings

arcjet/example-nextjs-fly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arcjet Logo

Arcjet + Fly.io example app

Arcjet helps developers protect their apps in just a few lines of code. This is an example application demonstrating the use of multiple features.

This example is deployed at https://example.arcjet.com.

Features

  • Signup form protection uses Arcjet's server-side email verification configured to block disposable providers and ensure that the domain has a valid MX record. It also includes rate limiting and bot protection to prevent automated abuse.
  • Bot protection shows how a page can be protected from automated clients.
  • Rate limiting shows the use of different rate limit configurations depending on the authenticated user. A logged-in user can make more requests than an anonymous user.
  • Attack protection demonstrates Arcjet Shield, which detects suspicious behavior, such as SQL injection and cross-site scripting attacks.

 Deploy to Fly.io

  1. Set up a new Fly.io app
fly launch --name $YOUR_APP_NAME --no-deploy

Replace $YOUR_APP_NAME with whatever name you'd like. This command will generate a Dockerfile and a fly.toml for you.

  1. Create an Arcjet account and link it to your Fly.io app:
fly ext arcjet create
  1. Deploy to Fly.io:
fly deploy
  1. Open your app in your browser and try out the features.

  2. Review the request details in your Arcjet dashboard:

fly ext arcjet dashboard

Run locally

  1. Log into your Arcjet dashboard to get the ARCJET_KEY for your app.
fly ext arcjet dashboard
  1. Install dependencies:
npm ci
  1. Rename .env.local.example to .env.local and add your Arcjet key. If you want to test the rate limiting authentication, you will also need to add an Auth.js secret and create a GitHub OAuth app.

  2. Start the dev server

npm run dev
  1. Open http://localhost:3000 in your browser.

Stack