generated from hcp-uw/react-express-starter-template
-
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
Showing
47 changed files
with
3,139 additions
and
17,755 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 |
---|---|---|
@@ -1,65 +1,93 @@ | ||
# Node.js (React, Express) Project Starter ✅ | ||
<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> | ||
|
||
A simple template repository with a React frontend and Express backend for quickly starting new full-stack projects. | ||
<p align="center"> | ||
The fastest way to build apps with Next.js and Supabase | ||
</p> | ||
|
||
## Prerequisites ‼️ | ||
<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/> | ||
|
||
To use this template, you need to have the following installed on your machine: | ||
## Features | ||
|
||
- Node.js | ||
- npm | ||
- 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) | ||
- Optional deployment with [Supabase Vercel Integration and Vercel deploy](#deploy-your-own) | ||
- Environment variables automatically assigned to Vercel project | ||
|
||
## Getting Started ▶️ | ||
## Demo | ||
|
||
These instructions will help you get a copy of the project up and running on your local machine for development and testing purposes. | ||
You can view a fully working demo at [demo-nextjs-with-supabase.vercel.app](https://demo-nextjs-with-supabase.vercel.app/). | ||
|
||
### Installation 💭 | ||
## Deploy to Vercel | ||
|
||
1. Clone the repository to your local machine: | ||
Vercel deployment will guide you through creating a Supabase account and project. | ||
|
||
```bash | ||
git clone https://github.com/hcp-uw/project-starter-template.git | ||
``` | ||
After installation of the Supabase integration, all relevant environment variables will be assigned to the project so the deployment is fully functioning. | ||
|
||
2. Change into the project's directory: | ||
[](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%20starter%20configures%20Supabase%20Auth%20to%20use%20cookies%2C%20making%20the%20user's%20session%20available%20throughout%20the%20entire%20Next.js%20app%20-%20Client%20Components%2C%20Server%20Components%2C%20Route%20Handlers%2C%20Server%20Actions%20and%20Middleware.&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&integration-ids=oac_VqOgBHqhEoFTPzGkPd7L0iH6) | ||
|
||
```bash | ||
cd project-starter-template | ||
``` | ||
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). | ||
|
||
3. Install the required dependencies for both the frontend and backend: | ||
## Clone and run locally | ||
|
||
```bash | ||
cd starter-frontend | ||
npm i | ||
cd ../starter-backend | ||
npm i | ||
``` | ||
1. You'll first need a Supabase project which can be made [via the Supabase dashboard](https://database.new) | ||
|
||
## Development 💻 | ||
2. Create a Next.js app using the Supabase Starter template npx command | ||
|
||
To start the development environment, follow these steps: | ||
```bash | ||
npx create-next-app -e with-supabase | ||
``` | ||
|
||
1. Start your server (from the root of the project): | ||
3. Use `cd` to change into the app's directory | ||
|
||
```bash | ||
cd starter-backend | ||
npm start | ||
``` | ||
```bash | ||
cd name-of-new-app | ||
``` | ||
|
||
2. In a new terminal window (starting from the root of your project): | ||
```bash | ||
cd starter-frontend | ||
npm start | ||
``` | ||
4. Rename `.env.local.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] | ||
``` | ||
|
||
### Authors 📝 | ||
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) | ||
|
||
[Elijah Melton](https://github.com/elimelt) | ||
5. You can now run the Next.js local development server: | ||
|
||
### Contributing 🤝 | ||
```bash | ||
npm run dev | ||
``` | ||
|
||
If you have any feedback feel free to submit an issue/pull request! Contributions are more than welcome. | ||
The starter kit should now be running on [localhost:3000](http://localhost:3000/). | ||
|
||
> 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,19 @@ | ||
import { createClient } from "@/utils/supabase/server"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export async function GET(request: Request) { | ||
// The `/auth/callback` route is required for the server-side auth flow implemented | ||
// by the SSR package. It exchanges an auth code for the user's session. | ||
// https://supabase.com/docs/guides/auth/server-side/nextjs | ||
const requestUrl = new URL(request.url); | ||
const code = requestUrl.searchParams.get("code"); | ||
const origin = requestUrl.origin; | ||
|
||
if (code) { | ||
const supabase = createClient(); | ||
await supabase.auth.exchangeCodeForSession(code); | ||
} | ||
|
||
// URL to redirect to after sign up process completes | ||
return NextResponse.redirect(`${origin}/protected`); | ||
} |
Binary file not shown.
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,42 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer base { | ||
:root { | ||
--background: 200 20% 98%; | ||
--btn-background: 200 10% 91%; | ||
--btn-background-hover: 200 10% 89%; | ||
--foreground: 200 50% 3%; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
:root { | ||
--background: 200 50% 3%; | ||
--btn-background: 200 10% 9%; | ||
--btn-background-hover: 200 10% 12%; | ||
--foreground: 200 20% 96%; | ||
} | ||
} | ||
} | ||
|
||
@layer base { | ||
* { | ||
@apply border-foreground/20; | ||
} | ||
} | ||
|
||
.animate-in { | ||
animation: animateIn 0.3s ease 0.15s both; | ||
} | ||
|
||
@keyframes animateIn { | ||
from { | ||
opacity: 0; | ||
transform: translateY(10px); | ||
} | ||
to { | ||
opacity: 1; | ||
transform: translateY(0); | ||
} | ||
} |
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,28 @@ | ||
import { GeistSans } from "geist/font/sans"; | ||
import "./globals.css"; | ||
|
||
const defaultUrl = process.env.VERCEL_URL | ||
? `https://${process.env.VERCEL_URL}` | ||
: "http://localhost:3000"; | ||
|
||
export const metadata = { | ||
metadataBase: new URL(defaultUrl), | ||
title: "Next.js and Supabase Starter Kit", | ||
description: "The fastest way to build apps with Next.js and Supabase", | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<html lang="en" className={GeistSans.className}> | ||
<body className="bg-background text-foreground"> | ||
<main className="min-h-screen flex flex-col items-center"> | ||
{children} | ||
</main> | ||
</body> | ||
</html> | ||
); | ||
} |
Oops, something went wrong.