Next.js application that enables you to create, read, update, and delete user profiles by interacting with a Couchbase Capella database.
The deployment instructions are specifically for Vercel. If you are deploying on other platforms, you need to adapt the instructions for running the project locally.
To deploy this project on Vercel, you will need:
user_profile
, and a collection called profile
(within the _default
scope).build
step will attempt to create the collection and load the sample data within your CB_BUCKET
on deployment.Query failed: bucket not found
OR Query failed: parsing error
CB_BUCKET
environment variable, a _default
scope, and a collection named profile
.https://couchbase-nextjs-quickstart.vercel.app/
To run this project locally, you will need:
Clone the source code:
git clone https://github.com/couchbase-examples/nextjs-quickstart.git
Install required dependencies:
npm install
If you are using Capella, you'll have to manually create a bucket named user_profile
and a collection named profile
. See the documentation on managing buckets and creating a collection for more information. Note that this collection should be created on the _default
scope.
We've included a .env.local.example
file with blank values for you to copy into a file called .env.local
and fill in the values. We've also included a .env.default
file for testing and running in GitPod. In most cases, you can ignore the default config file.
CB_USERNAME
- The username of an authorized user on your database. Follow these instructions to create database credentials on Capella.CB_PASSWORD
- The password that corresponds to the user specified above.CB_CONNECT_STRING
- The Couchbase connection string. Use the connection string specified on the 'Connect' tab within Capella (formatted like couchbases://cb.<xxxxxx>.cloud.couchbase.com
) or couchbase://localhost
for a local/Docker database.CB_BUCKET
- The bucket you'd like to connect to. Set this to user_profiles
for this template.If you have Couchbase running locally, we can create the bucket and collection by running the following command:
npm run init-db:local
If you'd like to add the sample data, run:
npm run load-sample-data
Note: this will also attempt to create a profile
collection.
Extra Step for Capella Databases: if you've manually set up your bucket and collection, you'll need to create the necessary indices as well. To accomplish this, run:
npm run build-indexes
This is because the index creation code is contained within the database initialization script, which we don't use for Capella databases.
Now we're ready to run our application:
npm run dev
If everything is configured properly, you should be able to navigate to localhost:3000 to see the example application. For troubleshooting and additional setup instructions please refer to the NextJS_README.md
included in the with-couchbase starter.
MOCK_DATA.json
file containing 15 documents with various mocked user data. The build
step will automatically load the sample data, but you may want to also load it manually for local testing. Use npm run load-sample-data
to insert the documents to your database. Be sure your local environment variables are set correctly!.env.default
file which is used for testing and gitpod instances of the project to ensure smooth setup in these environments.origin
variable instead of hard coding http://localhost:3000
to ensure requests work when running in other environments.user_profile
and then within that buckets default scope, a collection called profile
. See here for more info on managing buckets in Capella.. After bucket and collection creation, you can use the index creation command: npm run build-indexes
. Running npm run init-db:local
will also work to create the required indices. The bucket and collection creation steps will fail with ECONNREFUSED
but it will still be able to create the index on your Capella database.A suite of integration tests has been included, and can be run by first setting up the database:
npm run init-db:default
and then using the npm test
command.
Next.js application that enables you to create, read, update, and delete user profiles by interacting with a Couchbase Capella database.
The deployment instructions are specifically for Vercel. If you are deploying on other platforms, you need to adapt the instructions for running the project locally.
To deploy this project on Vercel, you will need:
user_profile
, and a collection called profile
(within the _default
scope).build
step will attempt to create the collection and load the sample data within your CB_BUCKET
on deployment.Query failed: bucket not found
OR Query failed: parsing error
CB_BUCKET
environment variable, a _default
scope, and a collection named profile
.https://couchbase-nextjs-quickstart.vercel.app/
To run this project locally, you will need:
Clone the source code:
git clone https://github.com/couchbase-examples/nextjs-quickstart.git
Install required dependencies:
npm install
If you are using Capella, you'll have to manually create a bucket named user_profile
and a collection named profile
. See the documentation on managing buckets and creating a collection for more information. Note that this collection should be created on the _default
scope.
We've included a .env.local.example
file with blank values for you to copy into a file called .env.local
and fill in the values. We've also included a .env.default
file for testing and running in GitPod. In most cases, you can ignore the default config file.
CB_USERNAME
- The username of an authorized user on your database. Follow these instructions to create database credentials on Capella.CB_PASSWORD
- The password that corresponds to the user specified above.CB_CONNECT_STRING
- The Couchbase connection string. Use the connection string specified on the 'Connect' tab within Capella (formatted like couchbases://cb.<xxxxxx>.cloud.couchbase.com
) or couchbase://localhost
for a local/Docker database.CB_BUCKET
- The bucket you'd like to connect to. Set this to user_profiles
for this template.If you have Couchbase running locally, we can create the bucket and collection by running the following command:
npm run init-db:local
If you'd like to add the sample data, run:
npm run load-sample-data
Note: this will also attempt to create a profile
collection.
Extra Step for Capella Databases: if you've manually set up your bucket and collection, you'll need to create the necessary indices as well. To accomplish this, run:
npm run build-indexes
This is because the index creation code is contained within the database initialization script, which we don't use for Capella databases.
Now we're ready to run our application:
npm run dev
If everything is configured properly, you should be able to navigate to localhost:3000 to see the example application. For troubleshooting and additional setup instructions please refer to the NextJS_README.md
included in the with-couchbase starter.
MOCK_DATA.json
file containing 15 documents with various mocked user data. The build
step will automatically load the sample data, but you may want to also load it manually for local testing. Use npm run load-sample-data
to insert the documents to your database. Be sure your local environment variables are set correctly!.env.default
file which is used for testing and gitpod instances of the project to ensure smooth setup in these environments.origin
variable instead of hard coding http://localhost:3000
to ensure requests work when running in other environments.user_profile
and then within that buckets default scope, a collection called profile
. See here for more info on managing buckets in Capella.. After bucket and collection creation, you can use the index creation command: npm run build-indexes
. Running npm run init-db:local
will also work to create the required indices. The bucket and collection creation steps will fail with ECONNREFUSED
but it will still be able to create the index on your Capella database.A suite of integration tests has been included, and can be run by first setting up the database:
npm run init-db:default
and then using the npm test
command.