我正在构建一个全栈应用程序:这些是我将要使用的库......
您可以使用无数的框架和库来改进您的全栈应用程序。
我们将介绍一些令人兴奋的概念,例如应用内通知、使用 React 制作视频,以及从开发人员的电子邮件 API 到在浏览器中创建交互式音乐。
那我们就开始吧。
(不要忘记给这些图书馆加注星标以表示您的支持)。
1. CopilotKit - 数小时内为您的产品提供 AI 辅助驾驶。
您可以使用两个 React 组件将关键的 AI 功能集成到 React 应用中。它们还提供内置(完全可定制)的 Copilot 原生 UX 组件,例如<CopilotKit />
、<CopilotPopup />
、<CopilotSidebar />
、<CopilotTextarea />
。
使用以下 npm 命令开始。
npm i @copilotkit/react-core @copilotkit/react-ui @copilotkit/react-textarea
这就是您集成 CopilotTextArea 的方法。
import { CopilotTextarea } from "@copilotkit/react-textarea";
import { useState } from "react";
export function SomeReactComponent() {
const [text, setText] = useState("");
return (
<>
<CopilotTextarea
className="px-4 py-4"
value={text}
onValueChange={(value: string) => setText(value)}
placeholder="What are your plans for your vacation?"
autosuggestionsConfig={{
textareaPurpose: "Travel notes from the user's previous vacations. Likely written in a colloquial style, but adjust as needed.",
chatApiConfigs: {
suggestionsApiConfig: {
forwardedParams: {
max_tokens: 20,
stop: [".", "?", "!"],
},
},
},
}}
/>
</>
);
}
您可以阅读文档。
其基本思想是在几分钟内构建可用于基于 LLM 的全栈应用程序的 AI 聊天机器人。
2. Storybook ——UI 开发、测试和文档变得简单。
Storybook 是一个用于独立构建 UI 组件和页面的前端工作室。它有助于 UI 开发、测试和文档编制。
他们在 GitHub 上有 57k+ 次提交、81k+ 次星标和 1300+ 次发布。
这就是为您的项目创建简单组件的方法。
import type { Meta, StoryObj } from '@storybook/react';
import { YourComponent } from './YourComponent';
//👇 This default export determines where your story goes in the story list
const meta: Meta<typeof YourComponent> = {
component: YourComponent,
};
export default meta;
type Story = StoryObj<typeof YourComponent>;
export const FirstStory: Story = {
args: {
//👇 The args you need here will depend on your component
},
};
您可以阅读文档。
如今,UI 很难调试,因为它们纠缠于业务逻辑、交互状态和应用程序上下文。
Storybook 提供了一个独立的 iframe 来渲染组件,不受应用业务逻辑和上下文的干扰。这有助于你将开发重点放在组件的每个变体上,即使是难以触及的边缘情况。
3. Appwrite——您的后端减少了麻烦。
Appwrite 的开源平台允许您向您的产品添加 Auth、DB、功能和存储,并构建任何规模的任何应用程序,拥有您的数据,并使用您喜欢的编码语言和工具。
他们有很好的贡献指南,甚至不厌其烦地详细解释架构。
使用以下 npm 命令开始。
npm install appwrite
您可以创建这样的登录组件。
"use client";
import { useState } from "react";
import { account, ID } from "./appwrite";
const LoginPage = () => {
const [loggedInUser, setLoggedInUser] = useState(null);
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [name, setName] = useState("");
const login = async (email, password) => {
const session = await account.createEmailSession(email, password);
setLoggedInUser(await account.get());
};
const register = async () => {
await account.create(ID.unique(), email, password, name);
login(email, password);
};
const logout = async () => {
await account.deleteSession("current");
setLoggedInUser(null);
};
if (loggedInUser) {
return (
<div>
<p>Logged in as {loggedInUser.name}</p>
<button type="button" onClick={logout}>
Logout
</button>
</div>
);
}
return (
<div>
<p>Not logged in</p>
<form>
<input
type="email"
placeholder="Email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<input
type="password"
placeholder="Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<input
type="text"
placeholder="Name"
value={name}
onChange={(e) => setName(e.target.value)}
/>
<button type="button" onClick={() => login(email, password)}>
Login
</button>
<button type="button" onClick={register}>
Register
</button>
</form>
</div>
);
};
export default LoginPage;
您可以阅读文档。
Appwrite 可以非常轻松地构建具有开箱即用扩展功能的可扩展后端应用程序。
4. Wasp – 类似 Rails 的 react、node.js 和 prisma 框架。
使用 React 和 Node.js 开发全栈 Web 应用的最快方法。这并非空想,而是构建极速全栈应用的另一种方式。
这就是将其集成到组件中的方法。
import getRecipes from "@wasp/queries/getRecipes";
import { useQuery } from "@wasp/queries";
import type { User } from "@wasp/entities";
export function HomePage({ user }: { user: User }) {
// Due to full-stack type safety, `recipes` will be of type `Recipe[]` here.
const { data: recipes, isLoading } = useQuery(getRecipes); // Calling our query here!
if (isLoading) {
return <div>Loading...</div>;
}
return (
<div>
<h1>Recipes</h1>
<ul>
{recipes ? recipes.map((recipe) => (
<li key={recipe.id}>
<div>{recipe.title}</div>
<div>{recipe.description}</div>
</li>
)) : 'No recipes defined yet!'}
</ul>
</div>
);
}
您可以阅读文档。
5. Novu——为您的应用添加应用内通知!
Novu 提供了一个开源通知基础设施,其中包含功能齐全的嵌入式通知中心。
React
这就是您可以创建用于应用内通知的novu 组件的方法。
import {
NovuProvider,
PopoverNotificationCenter,
NotificationBell,
} from "@novu/notification-center";
function App() {
return (
<>
<NovuProvider
subscriberId={process.env.REACT_APP_SUB_ID}
applicationIdentifier={process.env.REACT_APP_APP_ID}
>
<PopoverNotificationCenter>
{({ unseenCount }) => <NotificationBell unseenCount={unseenCount} />}
</PopoverNotificationCenter>
</NovuProvider>
</>
);
}
export default App;
您可以阅读文档。
6. Remotion——使用 React 以编程方式制作视频。
使用 React 创建真正的 MP4 视频,使用服务器端渲染和参数化扩展您的视频制作。
使用以下 npm 命令开始。
npm init video
它为您提供一个帧编号和一个空白画布,您可以在其中使用 React 渲染任何您想要的内容。
这是一个将当前帧呈现为文本的示例 React 组件。
import { AbsoluteFill, useCurrentFrame } from "remotion";
export const MyComposition = () => {
const frame = useCurrentFrame();
return (
<AbsoluteFill
style={{
justifyContent: "center",
alignItems: "center",
fontSize: 100,
backgroundColor: "white",
}}
>
The current frame is {frame}.
</AbsoluteFill>
);
};
您可以阅读文档。
remotion 团队在过去两年中因制作 GitHub Wrapped 而闻名。
7. NocoDB ——Airtable 的替代品。
Airtable 的免费开源替代品是 NocoDB。它可以使用任何 MySQL、PostgreSQL、SQL Server、SQLite 或 MariaDB 数据库创建智能电子表格。
其主要目标是使强大的计算工具得到更广泛的应用。
从以下 npx 命令开始。
npx create-nocodb-app
您可以阅读文档。
NocoDB 的创建是为了向世界各地的数字企业提供强大的开源和无代码数据库界面。
您可以非常快速地将您的 airtable 数据导入 NocoDB。
8. Novel——具有人工智能自动完成功能的所见即所得编辑器。
它使用Next.js
、、作为文本编辑器Vercel AI SDK
。Tiptap
使用以下 npm 命令开始。
npm i novel
以下是如何使用它的方法。有多种选项可用于改进您的申请。
import { Editor } from "novel";
export default function App() {
return <Editor />;
}
9. Blitz——缺少 NextJS 的全栈工具包。
Blitz 从 Next.js 的不足之处继续前进,为全球应用程序的运输和扩展提供经过实践检验的库和约定。
使用以下 npm 命令开始。
npm install -g blitz
这就是使用 Blitz 构建新页面的方法。
const NewProjectPage: BlitzPage = () => {
const router = useRouter()
const [createProjectMutation] = useMutation(createProject)
return (
<div>
<h1>Create New Project</h1>
<ProjectForm
submitText="Create Project"
schema={CreateProject}
onSubmit={async (values) => {
// This is equivalent to calling the server function directly
const project = await createProjectMutation(values)
// Notice the 'Routes' object Blitz provides for routing
router.push(Routes.ProjectsPage({ projectId: project.id }))
}}
/>
</div>
);
};
NewProjectPage.authenticate = true
NewProjectPage.getLayout = (page) => <Layout>{page}</Layout>
export default NewProjectPage
您可以阅读文档。
它使建筑物的质量提高了好几倍。
10. Supabase——开源 Firebase 替代品。
我们大多数人已经预料到 supabase 会出现在这里,因为它太棒了。
使用以下 npm 命令 (Next.js) 开始。
npx create-next-app -e with-supabase
这就是使用 supabase 创建用户的方法。
import { createClient } from '@supabase/supabase-js'
// Initialize
const supabaseUrl = 'https://chat-room.supabase.co'
const supabaseKey = 'public-anon-key'
const supabase = createClient(supabaseUrl, supabaseKey)
// Create a new user
const { user, error } = await supabase.auth.signUp({
email: 'example@email.com',
password: 'example-password',
})
您可以阅读文档。
您可以构建一个速度超快的应用程序,包含 Auth、实时功能、Edge 函数、存储等等。Supabase 应有尽有!
他们还提供一些入门套件,如 AI Chatbot 和 Stripe Subscriptions。
11. Refine – 面向企业的开源改造。
以无与伦比的灵活性构建管理面板、仪表板和 B2B 应用程序
只需不到一分钟,即可使用单个 CLI 命令进行设置。
它拥有 15 多个后端服务的连接器,包括 Hasura、Appwrite 等。
使用以下 npm 命令开始。
npm create refine-app@latest
使用 Refine 添加登录就是这么简单。
import { useLogin } from "@refinedev/core";
const { login } = useLogin();
您可以阅读文档。
12. Zenstack——几分钟内即可从数据库到 API 和 UI。
TypeScript 工具包通过强大的访问控制层增强了 Prisma ORM,并释放了其全栈开发的全部功能。
从以下 npx 命令开始。
npx zenstack@latest init
这就是如何通过服务器适配器创建 RESTful API。
// pages/api/model/[...path].ts
import { requestHandler } from '@zenstackhq/next';
import { enhance } from '@zenstackhq/runtime';
import { getSessionUser } from '@lib/auth';
import { prisma } from '@lib/db';
// Mount Prisma-style APIs: "/api/model/post/findMany", "/api/model/post/create", etc.
// Can be configured to provide standard RESTful APIs (using JSON:API) instead.
export default requestHandler({
getPrisma: (req, res) => enhance(prisma, { user: getSessionUser(req, res) }),
});
您可以阅读文档。
13. Buildship——低代码可视化后端构建器。
对于您正在构建的应用程序,使用无代码应用程序构建器(FlutterFlow、Webflow、Framer、Adalo、Bubble、BravoStudio……)或前端框架(Next.js、React、Vue……),您需要一个后端来支持可扩展的 API、安全的工作流、自动化等。BuildShip 为您提供了一种完全可视化的方式,以易于使用的完全托管体验可扩展地构建这些后端任务。
这意味着您无需在云平台上处理或部署事物、执行 DevOps 等。只需立即构建和交付即可🚀
14. Taipy——将数据和 AI 算法融入可投入生产的 Web 应用程序中。
Taipy 是一个开源 Python 库,用于轻松进行端到端应用程序开发,
具有假设分析、智能管道执行、内置调度和部署工具。
使用以下命令开始。
pip install taipy
这是一个典型的 Python 函数,也是过滤场景中唯一使用的任务。
def filter_genre(initial_dataset: pd.DataFrame, selected_genre):
filtered_dataset = initial_dataset[initial_dataset['genres'].str.contains(selected_genre)]
filtered_data = filtered_dataset.nlargest(7, 'Popularity %')
return filtered_data
您可以阅读文档。
他们还有很多您可以构建的演示应用程序教程。
15. LocalForage——改进了离线存储。
LocalForage 是一个 JavaScript 库,它使用类似 localStorage 的简单 API 来异步存储数据,从而提升 Web 应用的离线体验。它允许开发者存储多种类型的数据,而不仅仅是字符串。
使用以下 npm 命令开始。
npm install localforage
只需包含 JS 文件并开始使用 localForage。
<script src="localforage.js"></script>
您可以阅读文档。
16. Zod——具有静态类型推断的 TypeScript 优先模式验证。
Zod 旨在通过最大限度地减少重复的类型声明来提高开发者友好度。使用 Zod,您只需声明一次验证器,Zod 就会自动推断静态 TypeScript 类型。这样,您可以轻松地将简单的类型组合成复杂的数据结构。
使用以下 npm 命令开始。
npm install zod
这就是在创建字符串模式时自定义一些常见错误消息的方法。
const name = z.string({
required_error: "Name is required",
invalid_type_error: "Name must be a string",
});
您可以阅读文档。
它适用于 Node.js 和所有现代浏览器
17.多普勒——管理你的秘密。
您可以通过在具有开发、暂存和生产环境的项目中组织秘密来消除秘密蔓延。
使用以下命令开始(MacOS)。
$ brew install dopplerhq/cli/doppler
$ doppler --version
这是安装 Doppler CLI 的GitHub Actions 工作流程。
您可以阅读文档。
name: Example action
on: [push]
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Install CLI
uses: dopplerhq/cli-action@v3
- name: Do something with the CLI
run: doppler secrets --only-names
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
18. FastAPI——高性能、易于学习、快速编码、可立即投入生产。
FastAPI 是一个现代的、快速的(高性能)Web 框架,用于基于标准 Python 类型提示使用 Python 3.8+ 构建 API。
使用以下命令开始。
$ pip install fastapi
这就是您可以开始使用 FastAPI 的方式。
from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
您的编辑器将自动完成属性并了解其类型,这是使用 FastAPI 的最佳功能之一。
您可以阅读文档。
19. Flowise——拖放 UI 来构建您的自定义 LLM 流程。
Flowise 是一个开源 UI 可视化工具,用于构建您的定制 LLM 编排流程和 AI 代理。
使用以下 npm 命令开始。
npm install -g flowise
npx flowise start
OR
npx flowise start --FLOWISE_USERNAME=user --FLOWISE_PASSWORD=1234
这就是您集成 API 的方式。
import requests
url = "/api/v1/prediction/:id"
def query(payload):
response = requests.post(
url,
json = payload
)
return response.json()
output = query({
question: "hello!"
)}
您可以阅读文档。
20. Scrapy——一个快速的高级 Python Web 爬虫和抓取框架。
Scrapy 是一个快速的高级 Web 爬虫和网页抓取框架,用于爬取网站并从其页面中提取结构化数据。它可用于从数据挖掘到监控和自动化测试等各种用途。
使用以下命令开始。
pip install scrapy
构建并运行您的网络蜘蛛。
pip install scrapy
cat > myspider.py <<EOF
import scrapy
class BlogSpider(scrapy.Spider):
name = 'blogspider'
start_urls = ['https://www.zyte.com/blog/']
def parse(self, response):
for title in response.css('.oxy-post-title'):
yield {'title': title.css('::text').get()}
for next_page in response.css('a.next'):
yield response.follow(next_page, self.parse)
EOF
scrapy runspider myspider.py
您可以阅读文档。
它拥有大约 50k+ 颗星,因此对于网络抓取来说具有巨大的可信度。
21. Tone——在浏览器中制作互动音乐。
使用以下 npm 命令开始。
npm install tone
这是您开始使用 Tone.js 的方法
// To import Tone.js:
import * as Tone from 'tone'
//create a synth and connect it to the main output (your speakers)
const synth = new Tone.Synth().toDestination();
//play a middle 'C' for the duration of an 8th note
synth.triggerAttackRelease("C4", "8n");
您可以阅读文档。
22. Spacetime——轻量级的 javascript 时区库。
您可以计算远程时区的时间;支持夏令时、闰年和半球。您可以按季度、季节、月份、星期来调整时间。
使用以下 npm 命令开始。
npm install spacetime
您可以这样使用它。
<script src="https://unpkg.com/spacetime"></script>
<script>
var d = spacetime('March 1 2012', 'America/New_York')
//set the time
d = d.time('4:20pm')
d = d.goto('America/Los_Angeles')
d.time()
//'1:20pm'
</script>
23. Mermaid – 从类似 markdown 的文本生成图表。
您可以使用 Mermaid 从 Markdown 等文本生成流程图或序列图等图表。
这就是创建图表的方法。
sequenceDiagram
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
它将生成下图。
在实时编辑器中查看示例。
24.公共 API ——20 多个类别中的 1400 多个 API。
我们主要使用外部 API 来构建应用程序,您可以在这里找到所有 API 的列表。网站链接在文末。
它在 GitHub 上有大约 279k+ 个星。
从代码库里获取网站链接实在太难了。所以我把它粘贴到这里。
网站 - collective-api.vercel.app/
25. Framer Motion——像魔术一样的动画。
Framer 是目前最强大的动画库之一。
它使用简单的声明式语法,这意味着您可以编写更少的代码。更少的代码意味着您的代码库更易于阅读和维护。
您可以创建事件和手势,并且使用 Framer 的社区很大,这意味着良好的支持。
使用以下 npm 命令开始。
npm install framer-motion
您可以这样使用它。
import { motion } from "framer-motion"
<motion.div
whileHover={{ scale: 1.2 }}
whileTap={{ scale: 1.1 }}
drag="x"
dragConstraints={{ left: -100, right: 100 }}
/>
您可以阅读文档。
26.顺便说一句- 几分钟内即可建立您的个人博客。
您可以注册并使用 btw,无需安装任何东西。您也可以使用开源版本进行自主托管。
使用 btw 构建的示例博客。
27. Formbricks——开源调查平台。
Formbricks 提供免费开源的调查平台。通过精美的应用内、网站、链接和电子邮件调查,在用户旅程的每个环节收集反馈。您可以基于 Formbricks 进行构建,也可以利用预置的数据分析功能。
使用以下 npm 命令开始。
npm install @formbricks/js
这就是您可以开始使用 formbricks 的方式。
import formbricks from "@formbricks/js";
if (typeof window !== "undefined") {
formbricks.init({
environmentId: "claV2as2kKAqF28fJ8",
apiHost: "https://app.formbricks.com",
});
}
您可以阅读文档。
28. Stripe——支付基础设施。
数百万各种规模的公司在线上和线下使用 Stripe 来接受付款、发送付款、自动化财务流程并最终增加收入。
使用以下 npm 命令 (React.js) 开始。
npm install @stripe/react-stripe-js @stripe/stripe-js
这就是使用钩子的方法。
import React, {useState} from 'react';
import ReactDOM from 'react-dom';
import {loadStripe} from '@stripe/stripe-js';
import {
PaymentElement,
Elements,
useStripe,
useElements,
} from '@stripe/react-stripe-js';
const CheckoutForm = () => {
const stripe = useStripe();
const elements = useElements();
const [errorMessage, setErrorMessage] = useState(null);
const handleSubmit = async (event) => {
event.preventDefault();
if (elements == null) {
return;
}
// Trigger form validation and wallet collection
const {error: submitError} = await elements.submit();
if (submitError) {
// Show error to your customer
setErrorMessage(submitError.message);
return;
}
// Create the PaymentIntent and obtain clientSecret from your server endpoint
const res = await fetch('/create-intent', {
method: 'POST',
});
const {client_secret: clientSecret} = await res.json();
const {error} = await stripe.confirmPayment({
//`Elements` instance that was used to create the Payment Element
elements,
clientSecret,
confirmParams: {
return_url: 'https://example.com/order/123/complete',
},
});
if (error) {
// This point will only be reached if there is an immediate error when
// confirming the payment. Show error to your customer (for example, payment
// details incomplete)
setErrorMessage(error.message);
} else {
// Your customer will be redirected to your `return_url`. For some payment
// methods like iDEAL, your customer will be redirected to an intermediate
// site first to authorize the payment, then redirected to the `return_url`.
}
};
return (
<form onSubmit={handleSubmit}>
<PaymentElement />
<button type="submit" disabled={!stripe || !elements}>
Pay
</button>
{/* Show error message to your customers */}
{errorMessage && <div>{errorMessage}</div>}
</form>
);
};
const stripePromise = loadStripe('pk_test_6pRNASCoBOKtIshFeQd4XMUh');
const options = {
mode: 'payment',
amount: 1099,
currency: 'usd',
// Fully customizable with appearance API.
appearance: {
/*...*/
},
};
const App = () => (
<Elements stripe={stripePromise} options={options}>
<CheckoutForm />
</Elements>
);
ReactDOM.render(<App />, document.body);
您可以阅读文档。
你几乎可以集成任何东西。它拥有丰富的选项列表。
29. Upscayl——开源 AI 图像升频器。
一款免费开源的 AI 图像缩放工具,适用于 Linux、MacOS 和 Windows,秉承 Linux 优先的理念。
它可能与全栈无关,但对于图像缩放非常有用。
Upscayl 凭借先进的 AI 技术,帮您将低分辨率图像转换为高分辨率图像。清晰锐利!
30.重新发送——面向开发人员的电子邮件 API。
你可以使用 React 构建和发送电子邮件。这是 2023 年最受追捧的产品之一。
使用以下 npm 命令开始。
npm install @react-email/components -E
这就是将它与 next.js 项目集成的方法。
import { EmailTemplate } from '@/components/email-template';
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST() {
const { data, error } = await resend.emails.send({
from: 'onboarding@resend.dev',
to: 'delivered@resend.dev',
subject: 'Hello world',
react: EmailTemplate({ firstName: 'John' }),
});
if (error) {
return Response.json({ error });
}
return Response.json(data);
}
您可以阅读文档。
它的基本理念是打造简洁优雅的界面,让您几分钟内即可开始发送电子邮件。它兼容您常用编程语言的 SDK,可直接嵌入您的代码中。
呼!项目清单好长啊。
我知道你还有更多想法,分享它们,让我们一起建设:D
如今,构建全栈应用并不难,但每个应用都可以通过有效利用优秀的开源项目来提升其独特优势,从而解决各种问题。
例如,你可以构建一个可以发出通知或创建 UI 流程来抓取数据的应用。
希望这些内容能对你的开发之旅有所帮助。它们拥有一流的开发体验,值得你信赖。
因为您将要建造东西,所以您可以在这里找到一些疯狂的想法。
祝您拥有美好的一天!下次再见。
文章来源:https://dev.to/copilotkit/im-building-a-full-stack-app-here-are-the-libraries-im-going-to-use-51nk