-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0d8fae6
Showing
54 changed files
with
5,119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Update these with your Supabase details from your project settings > API | ||
# https://app.supabase.com/project/_/settings/api | ||
NEXT_PUBLIC_SUPABASE_URL=your-project-url | ||
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<a href="https://demo-nextjs-with-supabase.vercel.app/"> | ||
<img alt="Next.js and Supabase Starter Kit - the fastest way to build apps with Next.js and Supabase" src="https://demo-nextjs-with-supabase.vercel.app/opengraph-image.png"> | ||
<h1 align="center">Next.js and Supabase Starter Kit</h1> | ||
</a> | ||
|
||
<p align="center"> | ||
The fastest way to build apps with Next.js and Supabase | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="#features"><strong>Features</strong></a> · | ||
<a href="#demo"><strong>Demo</strong></a> · | ||
<a href="#deploy-to-vercel"><strong>Deploy to Vercel</strong></a> · | ||
<a href="#clone-and-run-locally"><strong>Clone and run locally</strong></a> · | ||
<a href="#feedback-and-issues"><strong>Feedback and issues</strong></a> | ||
<a href="#more-supabase-examples"><strong>More Examples</strong></a> | ||
</p> | ||
<br/> | ||
|
||
## Features | ||
|
||
- Works across the entire [Next.js](https://nextjs.org) stack | ||
- App Router | ||
- Pages Router | ||
- Middleware | ||
- Client | ||
- Server | ||
- It just works! | ||
- supabase-ssr. A package to configure Supabase Auth to use cookies | ||
- Styling with [Tailwind CSS](https://tailwindcss.com) | ||
- Components with [shadcn/ui](https://ui.shadcn.com/) | ||
- Optional deployment with [Supabase Vercel Integration and Vercel deploy](#deploy-your-own) | ||
- Environment variables automatically assigned to Vercel project | ||
|
||
## Demo | ||
|
||
You can view a fully working demo at [demo-nextjs-with-supabase.vercel.app](https://demo-nextjs-with-supabase.vercel.app/). | ||
|
||
## Deploy to Vercel | ||
|
||
Vercel deployment will guide you through creating a Supabase account and project. | ||
|
||
After installation of the Supabase integration, all relevant environment variables will be assigned to the project so the deployment is fully functioning. | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-supabase&project-name=nextjs-with-supabase&repository-name=nextjs-with-supabase&demo-title=nextjs-with-supabase&demo-description=This+starter+configures+Supabase+Auth+to+use+cookies%2C+making+the+user%27s+session+available+throughout+the+entire+Next.js+app+-+Client+Components%2C+Server+Components%2C+Route+Handlers%2C+Server+Actions+and+Middleware.&demo-url=https%3A%2F%2Fdemo-nextjs-with-supabase.vercel.app%2F&external-id=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-supabase&demo-image=https%3A%2F%2Fdemo-nextjs-with-supabase.vercel.app%2Fopengraph-image.png) | ||
|
||
The above will also clone the Starter kit to your GitHub, you can clone that locally and develop locally. | ||
|
||
If you wish to just develop locally and not deploy to Vercel, [follow the steps below](#clone-and-run-locally). | ||
|
||
## Clone and run locally | ||
|
||
1. You'll first need a Supabase project which can be made [via the Supabase dashboard](https://database.new) | ||
|
||
2. Create a Next.js app using the Supabase Starter template npx command | ||
|
||
```bash | ||
npx create-next-app -e with-supabase | ||
``` | ||
|
||
3. Use `cd` to change into the app's directory | ||
|
||
```bash | ||
cd name-of-new-app | ||
``` | ||
|
||
4. Rename `.env.example` to `.env.local` and update the following: | ||
|
||
``` | ||
NEXT_PUBLIC_SUPABASE_URL=[INSERT SUPABASE PROJECT URL] | ||
NEXT_PUBLIC_SUPABASE_ANON_KEY=[INSERT SUPABASE PROJECT API ANON KEY] | ||
``` | ||
|
||
Both `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` can be found in [your Supabase project's API settings](https://app.supabase.com/project/_/settings/api) | ||
|
||
5. You can now run the Next.js local development server: | ||
|
||
```bash | ||
npm run dev | ||
``` | ||
|
||
The starter kit should now be running on [localhost:3000](http://localhost:3000/). | ||
|
||
6. This template comes with the default shadcn/ui style initialized. If you instead want other ui.shadcn styles, delete `components.json` and [re-install shadcn/ui](https://ui.shadcn.com/docs/installation/next) | ||
|
||
> Check out [the docs for Local Development](https://supabase.com/docs/guides/getting-started/local-development) to also run Supabase locally. | ||
## Feedback and issues | ||
|
||
Please file feedback and issues over on the [Supabase GitHub org](https://github.com/supabase/supabase/issues/new/choose). | ||
|
||
## More Supabase examples | ||
|
||
- [Next.js Subscription Payments Starter](https://github.com/vercel/nextjs-subscription-payments) | ||
- [Cookie-based Auth and the Next.js 13 App Router (free course)](https://youtube.com/playlist?list=PL5S4mPUpp4OtMhpnp93EFSo42iQ40XjbF) | ||
- [Supabase Auth and the Next.js App Router](https://github.com/supabase/supabase/tree/master/examples/auth/nextjs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { forgotPasswordAction } from "@/app/actions"; | ||
import { FormMessage, Message } from "@/components/form-message"; | ||
import { SubmitButton } from "@/components/submit-button"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Label } from "@/components/ui/label"; | ||
import Link from "next/link"; | ||
import { SmtpMessage } from "../smtp-message"; | ||
|
||
export default function ForgotPassword({ | ||
searchParams, | ||
}: { | ||
searchParams: Message; | ||
}) { | ||
return ( | ||
<> | ||
<form className="flex-1 flex flex-col w-full gap-2 text-foreground [&>input]:mb-6 min-w-64 max-w-64 mx-auto"> | ||
<div> | ||
<h1 className="text-2xl font-medium">Reset Password</h1> | ||
<p className="text-sm text-secondary-foreground"> | ||
Already have an account?{" "} | ||
<Link className="text-primary underline" href="/sign-in"> | ||
Sign in | ||
</Link> | ||
</p> | ||
</div> | ||
<div className="flex flex-col gap-2 [&>input]:mb-3 mt-8"> | ||
<Label htmlFor="email">Email</Label> | ||
<Input name="email" placeholder="[email protected]" required /> | ||
<SubmitButton formAction={forgotPasswordAction}> | ||
Reset Password | ||
</SubmitButton> | ||
<FormMessage message={searchParams} /> | ||
</div> | ||
</form> | ||
<SmtpMessage /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default async function Layout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<div className="max-w-7xl flex flex-col gap-12 items-start">{children}</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { signInAction } from "@/app/actions"; | ||
import { FormMessage, Message } from "@/components/form-message"; | ||
import { SubmitButton } from "@/components/submit-button"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Label } from "@/components/ui/label"; | ||
import Link from "next/link"; | ||
|
||
export default function Login({ searchParams }: { searchParams: Message }) { | ||
return ( | ||
<form className="flex-1 flex flex-col min-w-64"> | ||
<h1 className="text-2xl font-medium">Sign in</h1> | ||
<p className="text-sm text-foreground"> | ||
Don't have an account?{" "} | ||
<Link className="text-foreground font-medium underline" href="/sign-up"> | ||
Sign up | ||
</Link> | ||
</p> | ||
<div className="flex flex-col gap-2 [&>input]:mb-3 mt-8"> | ||
<Label htmlFor="email">Email</Label> | ||
<Input name="email" placeholder="[email protected]" required /> | ||
<div className="flex justify-between items-center"> | ||
<Label htmlFor="password">Password</Label> | ||
<Link | ||
className="text-xs text-foreground underline" | ||
href="/forgot-password" | ||
> | ||
Forgot Password? | ||
</Link> | ||
</div> | ||
<Input | ||
type="password" | ||
name="password" | ||
placeholder="Your password" | ||
required | ||
/> | ||
<SubmitButton pendingText="Signing In..." formAction={signInAction}> | ||
Sign in | ||
</SubmitButton> | ||
<FormMessage message={searchParams} /> | ||
</div> | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { signUpAction } from "@/app/actions"; | ||
import { FormMessage, Message } from "@/components/form-message"; | ||
import { SubmitButton } from "@/components/submit-button"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Label } from "@/components/ui/label"; | ||
import Link from "next/link"; | ||
import { SmtpMessage } from "../smtp-message"; | ||
|
||
export default function Signup({ searchParams }: { searchParams: Message }) { | ||
if ("message" in searchParams) { | ||
return ( | ||
<div className="w-full flex-1 flex items-center h-screen sm:max-w-md justify-center gap-2 p-4"> | ||
<FormMessage message={searchParams} /> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<form className="flex flex-col min-w-64 max-w-64 mx-auto"> | ||
<h1 className="text-2xl font-medium">Sign up</h1> | ||
<p className="text-sm text text-foreground"> | ||
Already have an account?{" "} | ||
<Link className="text-primary font-medium underline" href="/sign-in"> | ||
Sign in | ||
</Link> | ||
</p> | ||
<div className="flex flex-col gap-2 [&>input]:mb-3 mt-8"> | ||
<Label htmlFor="email">Email</Label> | ||
<Input name="email" placeholder="[email protected]" required /> | ||
<Label htmlFor="password">Password</Label> | ||
<Input | ||
type="password" | ||
name="password" | ||
placeholder="Your password" | ||
minLength={6} | ||
required | ||
/> | ||
<SubmitButton formAction={signUpAction} pendingText="Signing up..."> | ||
Sign up | ||
</SubmitButton> | ||
<FormMessage message={searchParams} /> | ||
</div> | ||
</form> | ||
<SmtpMessage /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ArrowUpRight, InfoIcon } from "lucide-react"; | ||
import Link from "next/link"; | ||
|
||
export function SmtpMessage() { | ||
return ( | ||
<div className="bg-muted/50 px-5 py-3 border rounded-md flex gap-4"> | ||
<InfoIcon size={16} className="mt-0.5" /> | ||
<div className="flex flex-col gap-1"> | ||
<small className="text-sm text-secondary-foreground"> | ||
<strong> Note:</strong> Emails are rate limited. Enable Custom SMTP to | ||
increase the rate limit. | ||
</small> | ||
<div> | ||
<Link | ||
href="https://supabase.com/docs/guides/auth/auth-smtp" | ||
target="_blank" | ||
className="text-primary/50 hover:text-primary flex items-center text-sm gap-1" | ||
> | ||
Learn more <ArrowUpRight size={14} /> | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.